From df8d9550e7d872ca1716c5c9977731cadb6b9b6d Mon Sep 17 00:00:00 2001 From: Yan Jin Date: Tue, 22 Oct 2024 22:31:38 +1100 Subject: [PATCH 1/6] Fix issue #11938: Tab in empty text area field should focus the next field --- .../java/org/jabref/gui/fieldeditors/EditorTextArea.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java index fc18e591103..871a56545b5 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java +++ b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java @@ -10,6 +10,8 @@ import javafx.scene.control.ContextMenu; import javafx.scene.control.MenuItem; import javafx.scene.control.TextArea; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; import org.jabref.gui.ClipBoardManager; import org.jabref.gui.fieldeditors.contextmenu.EditorContextAction; @@ -27,6 +29,12 @@ public class EditorTextArea extends TextArea implements Initializable, ContextMe public EditorTextArea() { this(""); + this.addEventFilter(KeyEvent.KEY_PRESSED, event -> { + if (event.getCode() == KeyCode.TAB && this.getText().isEmpty()) { + this.getParent().requestFocus(); + event.consume(); + } + }); } public EditorTextArea(final String text) { From d194344ae08d07084b5582f12e4dbf8dc1dd29ec Mon Sep 17 00:00:00 2001 From: Yan Jin Date: Tue, 22 Oct 2024 23:16:08 +1100 Subject: [PATCH 2/6] Fix issue #11938: Tab in empty text area field should focus the next field --- .../java/org/jabref/gui/fieldeditors/EditorTextArea.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java index 871a56545b5..b4af125a0ba 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java +++ b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java @@ -28,15 +28,23 @@ public class EditorTextArea extends TextArea implements Initializable, ContextMe }; public EditorTextArea() { + // Call the constructor with an empty string this(""); + + // Add an event filter to handle key press events this.addEventFilter(KeyEvent.KEY_PRESSED, event -> { + // If the TAB key is pressed and the TextArea is empty if (event.getCode() == KeyCode.TAB && this.getText().isEmpty()) { + // Move the focus to the next parent element (likely the next form field) this.getParent().requestFocus(); + + // Consume the event to prevent further processing of the TAB key event.consume(); } }); } + public EditorTextArea(final String text) { super(text); From fed50b2c62e482e3bb04e81e681995298e7affa3 Mon Sep 17 00:00:00 2001 From: Yan Jin Date: Thu, 24 Oct 2024 21:17:00 +1100 Subject: [PATCH 3/6] Fix issue #11938: Tab in empty text area field should focus the next field --- src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java index b4af125a0ba..86f55a5ca9a 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java +++ b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java @@ -44,7 +44,6 @@ public EditorTextArea() { }); } - public EditorTextArea(final String text) { super(text); From 84277055c06a00932f24f0b2c3c9820e8f03b682 Mon Sep 17 00:00:00 2001 From: Yan Jin Date: Fri, 25 Oct 2024 14:44:52 +1100 Subject: [PATCH 4/6] Merge branch 'main' into fix-11938 Add event filter to move focus on TAB key press when TextArea is empty --- src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java index 86f55a5ca9a..e1b2cd7b89c 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java +++ b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java @@ -28,7 +28,7 @@ public class EditorTextArea extends TextArea implements Initializable, ContextMe }; public EditorTextArea() { - // Call the constructor with an empty string + // Call the constructor with an empty string. this(""); // Add an event filter to handle key press events From 870f7cfc8e4c323a7b88dac38839e457a98a1352 Mon Sep 17 00:00:00 2001 From: Yan Jin Date: Sat, 26 Oct 2024 21:50:51 +1100 Subject: [PATCH 5/6] Merge branch 'main' into fix-11938 # remove comment --- .../java/org/jabref/gui/fieldeditors/EditorTextArea.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java index e1b2cd7b89c..871a56545b5 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java +++ b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java @@ -28,17 +28,10 @@ public class EditorTextArea extends TextArea implements Initializable, ContextMe }; public EditorTextArea() { - // Call the constructor with an empty string. this(""); - - // Add an event filter to handle key press events this.addEventFilter(KeyEvent.KEY_PRESSED, event -> { - // If the TAB key is pressed and the TextArea is empty if (event.getCode() == KeyCode.TAB && this.getText().isEmpty()) { - // Move the focus to the next parent element (likely the next form field) this.getParent().requestFocus(); - - // Consume the event to prevent further processing of the TAB key event.consume(); } }); From d37f16b02686f36e75a6a61da817730e41e5f60d Mon Sep 17 00:00:00 2001 From: Yan Jin Date: Sun, 27 Oct 2024 14:09:47 +1100 Subject: [PATCH 6/6] Merge branch 'main' into fix-11938 # remove comment --- src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java index 871a56545b5..beb0e1a6b94 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java +++ b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java @@ -30,7 +30,7 @@ public class EditorTextArea extends TextArea implements Initializable, ContextMe public EditorTextArea() { this(""); this.addEventFilter(KeyEvent.KEY_PRESSED, event -> { - if (event.getCode() == KeyCode.TAB && this.getText().isEmpty()) { + if (event.getCode() == KeyCode.TAB && this.getText() != null && this.getText().isEmpty()) { this.getParent().requestFocus(); event.consume(); }