Re: ComboBox keypress discrepancy
Hi All, I have traced out the root cause responsible for the discrepancy between the behavior of ComboBox in JavaFX 8 vs later version. It turns out the change is in ListViewBehavior and was made under JEP-253[1]. ListView is used as the PopupContent Node in ComboBox. In JDK 8, ListView doesn't have any event handler for TAB key press event [2]. In JDK 9, a default mapping was added to the ListViewBehavior [3][4] which added the key press event handlers for TAB and SHIFT + TAB. Unfortunately, I haven't been able to find the reasoning behind the change. Is there a JBS issue or mailing list discussion that can throw some light on it? This discrepancy can also be reproduced with latest releases JDK 8 and JavaFX 14. Best regards, Abhinay [1] https://bugs.openjdk.java.net/browse/JDK-8076423 [2] https://github.com/openjdk/jfx/blob/48086c72c27237552d8794ff72b2e152a9a7cea1/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/ListViewBehavior.java#L65 [3] https://github.com/openjdk/jfx/blob/master/modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/behavior/ListViewBehavior.java#L81 [4] https://github.com/openjdk/jfx/blob/master/modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/behavior/FocusTraversalInputMap.java#L53 P.S. I sincerely hope everyone in this mailing list are healthy and safe! From: Abhinay Agarwal Sent: Sunday, March 8, 2020 1:51 PM To: Dirk Lemmermann Cc: openjfx-dev@openjdk.java.net Subject: Re: ComboBox keypress discrepancy Hi Dirk, Exactly. The TAB key press event not firing at all seems fishy. -- Abhinay From: Dirk Lemmermann Sent: Friday, March 6, 2020 2:55 PM To: Abhinay Agarwal Cc: openjfx-dev@openjdk.java.net Subject: Re: ComboBox keypress discrepancy Regarding expected behaviour: in native combo boxes / dropdowns on Mac the TAB key is doing nothing when the popup is open. If you want to select an item you need to use the arrow keys. So I guess that is what I would expect for navigating the element. But that does not mean that the key event can’t fire, right? Some subclass / custom control might have a need for it. Dirk Am 06.03.2020 um 05:59 schrieb Abhinay Agarwal mailto:abhinay_agar...@live.com>>: Hi Dirk, Thanks for reaching out. As stated earlier, I want to know what exactly is causing this change in behaviour. I also want to know what is the expected behaviour in this case: should TAB key press trigger when the popupwindow is showing? -- Abhinay From: Dirk Lemmermann mailto:dlemmerm...@gmail.com>> Sent: Thursday, March 5, 2020 6:39 PM To: Abhinay Agarwal mailto:abhinay_agar...@live.com>> Cc: openjfx-dev@openjdk.java.net<mailto:openjfx-dev@openjdk.java.net> mailto:openjfx-dev@openjdk.java.net>> Subject: Re: ComboBox keypress discrepancy So what info do you need? What test do you want us to run? I ran it on MacOS X with Java 14ea and I DO NOT see the „TAB“ output. Dirk Am 05.03.2020 um 11:43 schrieb Abhinay Agarwal mailto:abhinay_agar...@live.com>>: import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.ComboBox; import javafx.scene.input.KeyEvent; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage) { final ComboBox stringComboBox = new ComboBox<>(); stringComboBox.getItems().addAll("John", "Jacob", "Schmidt"); stringComboBox.addEventHandler(KeyEvent.KEY_PRESSED, kp -> System.out.println(kp.getCode())); final Scene scene = new Scene(new BorderPane(stringComboBox), 300, 275); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
Re: ComboBox keypress discrepancy
Hi Dirk, Exactly. The TAB key press event not firing at all seems fishy. -- Abhinay From: Dirk Lemmermann Sent: Friday, March 6, 2020 2:55 PM To: Abhinay Agarwal Cc: openjfx-dev@openjdk.java.net Subject: Re: ComboBox keypress discrepancy Regarding expected behaviour: in native combo boxes / dropdowns on Mac the TAB key is doing nothing when the popup is open. If you want to select an item you need to use the arrow keys. So I guess that is what I would expect for navigating the element. But that does not mean that the key event can’t fire, right? Some subclass / custom control might have a need for it. Dirk Am 06.03.2020 um 05:59 schrieb Abhinay Agarwal mailto:abhinay_agar...@live.com>>: Hi Dirk, Thanks for reaching out. As stated earlier, I want to know what exactly is causing this change in behaviour. I also want to know what is the expected behaviour in this case: should TAB key press trigger when the popupwindow is showing? -- Abhinay From: Dirk Lemmermann mailto:dlemmerm...@gmail.com>> Sent: Thursday, March 5, 2020 6:39 PM To: Abhinay Agarwal mailto:abhinay_agar...@live.com>> Cc: openjfx-dev@openjdk.java.net<mailto:openjfx-dev@openjdk.java.net> mailto:openjfx-dev@openjdk.java.net>> Subject: Re: ComboBox keypress discrepancy So what info do you need? What test do you want us to run? I ran it on MacOS X with Java 14ea and I DO NOT see the „TAB“ output. Dirk Am 05.03.2020 um 11:43 schrieb Abhinay Agarwal mailto:abhinay_agar...@live.com>>: import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.ComboBox; import javafx.scene.input.KeyEvent; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage) { final ComboBox stringComboBox = new ComboBox<>(); stringComboBox.getItems().addAll("John", "Jacob", "Schmidt"); stringComboBox.addEventHandler(KeyEvent.KEY_PRESSED, kp -> System.out.println(kp.getCode())); final Scene scene = new Scene(new BorderPane(stringComboBox), 300, 275); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
Re: ComboBox keypress discrepancy
Regarding expected behaviour: in native combo boxes / dropdowns on Mac the TAB key is doing nothing when the popup is open. If you want to select an item you need to use the arrow keys. So I guess that is what I would expect for navigating the element. But that does not mean that the key event can’t fire, right? Some subclass / custom control might have a need for it. Dirk > Am 06.03.2020 um 05:59 schrieb Abhinay Agarwal : > > Hi Dirk, > > Thanks for reaching out. As stated earlier, I want to know what exactly is > causing this change in behaviour. I also want to know what is the expected > behaviour in this case: should TAB key press trigger when the popupwindow is > showing? > > -- Abhinay > From: Dirk Lemmermann > Sent: Thursday, March 5, 2020 6:39 PM > To: Abhinay Agarwal > Cc: openjfx-dev@openjdk.java.net > Subject: Re: ComboBox keypress discrepancy > > So what info do you need? What test do you want us to run? > > I ran it on MacOS X with Java 14ea and I DO NOT see the „TAB“ output. > > Dirk > >> Am 05.03.2020 um 11:43 schrieb Abhinay Agarwal > <mailto:abhinay_agar...@live.com>>: >> >> import javafx.application.Application; >> import javafx.scene.Scene; >> import javafx.scene.control.ComboBox; >> import javafx.scene.input.KeyEvent; >> import javafx.scene.layout.BorderPane; >> import javafx.stage.Stage; >> >> public class Main extends Application { >> >>@Override >>public void start(Stage primaryStage) { >>final ComboBox stringComboBox = new ComboBox<>(); >>stringComboBox.getItems().addAll("John", "Jacob", "Schmidt"); >>stringComboBox.addEventHandler(KeyEvent.KEY_PRESSED, kp -> >> System.out.println(kp.getCode())); >> >>final Scene scene = new Scene(new BorderPane(stringComboBox), 300, >> 275); >>primaryStage.setScene(scene); >>primaryStage.show(); >>} >> >>public static void main(String[] args) { >>launch(args); >>} >> }
Re: ComboBox keypress discrepancy
Hi Dirk, Thanks for reaching out. As stated earlier, I want to know what exactly is causing this change in behaviour. I also want to know what is the expected behaviour in this case: should TAB key press trigger when the popupwindow is showing? -- Abhinay From: Dirk Lemmermann Sent: Thursday, March 5, 2020 6:39 PM To: Abhinay Agarwal Cc: openjfx-dev@openjdk.java.net Subject: Re: ComboBox keypress discrepancy So what info do you need? What test do you want us to run? I ran it on MacOS X with Java 14ea and I DO NOT see the „TAB“ output. Dirk Am 05.03.2020 um 11:43 schrieb Abhinay Agarwal mailto:abhinay_agar...@live.com>>: import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.ComboBox; import javafx.scene.input.KeyEvent; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage) { final ComboBox stringComboBox = new ComboBox<>(); stringComboBox.getItems().addAll("John", "Jacob", "Schmidt"); stringComboBox.addEventHandler(KeyEvent.KEY_PRESSED, kp -> System.out.println(kp.getCode())); final Scene scene = new Scene(new BorderPane(stringComboBox), 300, 275); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
Re: ComboBox keypress discrepancy
So what info do you need? What test do you want us to run? I ran it on MacOS X with Java 14ea and I DO NOT see the „TAB“ output. Dirk > Am 05.03.2020 um 11:43 schrieb Abhinay Agarwal : > > import javafx.application.Application; > import javafx.scene.Scene; > import javafx.scene.control.ComboBox; > import javafx.scene.input.KeyEvent; > import javafx.scene.layout.BorderPane; > import javafx.stage.Stage; > > public class Main extends Application { > >@Override >public void start(Stage primaryStage) { >final ComboBox stringComboBox = new ComboBox<>(); >stringComboBox.getItems().addAll("John", "Jacob", "Schmidt"); >stringComboBox.addEventHandler(KeyEvent.KEY_PRESSED, kp -> > System.out.println(kp.getCode())); > >final Scene scene = new Scene(new BorderPane(stringComboBox), 300, > 275); >primaryStage.setScene(scene); >primaryStage.show(); >} > >public static void main(String[] args) { >launch(args); >} > }
ComboBox keypress discrepancy
Hi, We have come across a behavioural change in ComboBox b/w JavaFX 8 and 9+. We are not sure if its a regression or a bug fix which is causing it. Therefore, I am reaching out to the community for insight. If you run the following example, open the popup window in ComboBox and press TAB: JavaFX 8 registers the key press event, where as, JavaFX 9 and later do not register it. The TAB keypress is registered successfully in bot cases when the popup window is not showing. import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.ComboBox; import javafx.scene.input.KeyEvent; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage) { final ComboBox stringComboBox = new ComboBox<>(); stringComboBox.getItems().addAll("John", "Jacob", "Schmidt"); stringComboBox.addEventHandler(KeyEvent.KEY_PRESSED, kp -> System.out.println(kp.getCode())); final Scene scene = new Scene(new BorderPane(stringComboBox), 300, 275); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }