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