Skip to content

Commit

Permalink
Merge pull request #4738 from CaptainDaVinci/fix-issue-4474
Browse files Browse the repository at this point in the history
Adding support for input methods
  • Loading branch information
Siedlerchr authored Mar 9, 2019
2 parents 1d4e2d1 + 917ddef commit f9a5575
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/main/java/org/jabref/gui/entryeditor/SourceTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.ListChangeListener;
import javafx.geometry.Point2D;
import javafx.scene.control.Tooltip;
import javafx.scene.input.InputMethodRequests;

import org.jabref.gui.DialogService;
import org.jabref.gui.icon.IconTheme;
Expand Down Expand Up @@ -77,9 +79,42 @@ private static String getSourceString(BibEntry entry, BibDatabaseMode type, Late
return stringWriter.getBuffer().toString();
}

/* Work around for different input methods.
* https://github.com/FXMisc/RichTextFX/issues/146
*/
private class InputMethodRequestsObject implements InputMethodRequests {

@Override
public String getSelectedText() {
return "";
}

@Override
public int getLocationOffset(int x, int y) {
return 0;
}

@Override
public void cancelLatestCommittedText() {
return;
}

@Override
public Point2D getTextLocation(int offset) {
return new Point2D(0, 0);
}
}

private CodeArea createSourceEditor() {
CodeArea codeArea = new CodeArea();
codeArea.setWrapText(true);
codeArea.setInputMethodRequests(new InputMethodRequestsObject());
codeArea.setOnInputMethodTextChanged(event -> {
String committed = event.getCommitted();
if (!committed.isEmpty()) {
codeArea.insertText(codeArea.getCaretPosition(), committed);
}
});
return codeArea;
}

Expand Down

0 comments on commit f9a5575

Please sign in to comment.