From d922e5597f7496515ca5e8d274190539405cc5ae Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 12 Jul 2017 23:58:07 +0200 Subject: [PATCH] Fix #2902: Tab in entry editor moves to next text area --- .../gui/fieldeditors/EditorTextArea.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java index 4ad8b9d2e0e..06a4a2179ed 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java +++ b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java @@ -7,6 +7,8 @@ import javafx.fxml.Initializable; import javafx.scene.control.ContextMenu; import javafx.scene.control.MenuItem; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; import com.sun.javafx.scene.control.skin.TextAreaSkin; @@ -24,6 +26,26 @@ public EditorTextArea(String text) { // Hide horizontal scrollbar and always wrap text setWrapText(true); + + // Should behave as a normal text field with respect to TAB behaviour + addEventFilter(KeyEvent.KEY_PRESSED, event -> { + if (event.getCode() == KeyCode.TAB) { + TextAreaSkin skin = (TextAreaSkin) getSkin(); + if (event.isShiftDown()) { + // Shift + Tab > previous text area + skin.getBehavior().traversePrevious(); + } else { + if (event.isControlDown()) { + // Ctrl + Tab > insert tab + skin.getBehavior().callAction("InsertTab"); + } else { + // Tab > next text area + skin.getBehavior().traverseNext(); + } + } + event.consume(); + } + }); } /**