From eed38787b6e56922087628ec5e279577ad85f908 Mon Sep 17 00:00:00 2001 From: leewyatt Date: Thu, 2 May 2024 14:58:09 +0900 Subject: [PATCH] Ensure consistent display behavior of Picker popup when closed using the Esc key. --- .../gemsfx/skins/ToggleVisibilityComboBoxSkin.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gemsfx/src/main/java/com/dlsc/gemsfx/skins/ToggleVisibilityComboBoxSkin.java b/gemsfx/src/main/java/com/dlsc/gemsfx/skins/ToggleVisibilityComboBoxSkin.java index 1e5522e6..b575a98c 100644 --- a/gemsfx/src/main/java/com/dlsc/gemsfx/skins/ToggleVisibilityComboBoxSkin.java +++ b/gemsfx/src/main/java/com/dlsc/gemsfx/skins/ToggleVisibilityComboBoxSkin.java @@ -2,6 +2,8 @@ import javafx.event.Event; import javafx.scene.control.ComboBoxBase; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; public abstract class ToggleVisibilityComboBoxSkin extends CustomComboBoxSkinBase { @@ -11,6 +13,14 @@ public abstract class ToggleVisibilityComboBoxSkin exten public ToggleVisibilityComboBoxSkin(T control) { super(control); + + // Pressed the esc key to hide the popup. + control.addEventFilter(KeyEvent.KEY_PRESSED, e -> { + if (e.getCode() == KeyCode.ESCAPE) { + showPopupOnMouseRelease = true; + hide(); + } + }); } @Override