Skip to content

Commit

Permalink
Ensure consistent display behavior of Picker popup when closed using …
Browse files Browse the repository at this point in the history
…the Esc key.
  • Loading branch information
leewyatt committed May 2, 2024
1 parent 2db0b87 commit eed3878
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends ComboBoxBase> extends CustomComboBoxSkinBase<T> {
Expand All @@ -11,6 +13,14 @@ public abstract class ToggleVisibilityComboBoxSkin<T extends ComboBoxBase> 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
Expand Down

0 comments on commit eed3878

Please sign in to comment.