Skip to content

Commit

Permalink
Fix #2902: Tab in entry editor moves to next text area
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Jul 12, 2017
1 parent 03861a3 commit d922e55
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
}
});
}

/**
Expand Down

0 comments on commit d922e55

Please sign in to comment.