As title. Run the test below to reproduce the issue. The Popup has setHideOnEscape(true).
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Point2D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.Background;
import javafx.scene.layout.VBox;
import javafx.stage.Popup;
import javafx.stage.Stage;
public class TextFieldInPopupBug {
public static class ComboBoxSetItemsBug extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
final Button button = new Button("Click to Show Popup");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
Popup popup = new Popup();
popup.setAutoHide(true);
popup.setHideOnEscape(true);
VBox box = new VBox(10, new TextField("Focus on this one, ESCAPE doesn't work"), new CheckBox("Focus on this one, ESCAPE works"));
box.setPadding(new Insets(10));
popup.getContent().addAll(box);
Point2D p = button.localToScreen(0, 0);
popup.show(button, p.getX(), p.getY() + button.getHeight());
}
});
VBox vbox = new VBox(6, button, new Label("Clicking on the button to show a popup. Focus on the text field and press ESCAPE. The popup doesn't hide." +
"\nYou can read comment in the file for more information"));
vbox.setPadding(new Insets(10));
Scene scene = new Scene(new Group());
stage.setTitle("TextField in Popup Bug");
((Group) scene.getRoot()).getChildren().addAll(vbox);
stage.setScene(scene);
stage.show();
}
}
}
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Point2D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.Background;
import javafx.scene.layout.VBox;
import javafx.stage.Popup;
import javafx.stage.Stage;
public class TextFieldInPopupBug {
public static class ComboBoxSetItemsBug extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
final Button button = new Button("Click to Show Popup");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
Popup popup = new Popup();
popup.setAutoHide(true);
popup.setHideOnEscape(true);
VBox box = new VBox(10, new TextField("Focus on this one, ESCAPE doesn't work"), new CheckBox("Focus on this one, ESCAPE works"));
box.setPadding(new Insets(10));
popup.getContent().addAll(box);
Point2D p = button.localToScreen(0, 0);
popup.show(button, p.getX(), p.getY() + button.getHeight());
}
});
VBox vbox = new VBox(6, button, new Label("Clicking on the button to show a popup. Focus on the text field and press ESCAPE. The popup doesn't hide." +
"\nYou can read comment in the file for more information"));
vbox.setPadding(new Insets(10));
Scene scene = new Scene(new Group());
stage.setTitle("TextField in Popup Bug");
((Group) scene.getRoot()).getChildren().addAll(vbox);
stage.setScene(scene);
stage.show();
}
}
}