33import java .util .logging .Logger ;
44
55import javafx .application .Platform ;
6- import javafx .event .ActionEvent ;
76import javafx .fxml .FXML ;
87import javafx .geometry .Pos ;
98import javafx .scene .chart .XYChart ;
109import javafx .scene .control .Label ;
11- import javafx .scene .control .MenuItem ;
12- import javafx .scene .control .TextInputControl ;
13- import javafx .scene .input .KeyCombination ;
14- import javafx .scene .input .KeyEvent ;
1510import javafx .scene .layout .HBox ;
1611import javafx .scene .layout .Priority ;
1712import javafx .scene .layout .StackPane ;
@@ -83,7 +78,6 @@ public MainWindow(Stage primaryStage, Logic logic) {
8378
8479 // Configure the UI
8580 setWindowDefaultSize (logic .getGuiSettings ());
86- setAccelerators ();
8781
8882 helpWindow = new HelpWindow ();
8983 notificationWindow = new NotificationWindow ();
@@ -94,39 +88,6 @@ public Stage getPrimaryStage() {
9488 return primaryStage ;
9589 }
9690
97- private void setAccelerators () {
98- // setAccelerator(helpMenuItem, KeyCombination.valueOf("F1"));
99- }
100-
101- /**
102- * Sets the accelerator of a MenuItem.
103- * @param keyCombination the KeyCombination value of the accelerator
104- */
105- private void setAccelerator (MenuItem menuItem , KeyCombination keyCombination ) {
106- menuItem .setAccelerator (keyCombination );
107-
108- /*
109- * TODO: the code below can be removed once the bug reported here
110- * https://bugs.openjdk.java.net/browse/JDK-8131666
111- * is fixed in later version of SDK.
112- *
113- * According to the bug report, TextInputControl (TextField, TextArea) will
114- * consume function-key events. Because CommandBox contains a TextField, and
115- * ResultDisplay contains a TextArea, thus some accelerators (e.g F1) will
116- * not work when the focus is in them because the key event is consumed by
117- * the TextInputControl(s).
118- *
119- * For now, we add following event filter to capture such key events and open
120- * help window purposely so to support accelerators even when focus is
121- * in CommandBox or ResultDisplay.
122- */
123- getRoot ().addEventFilter (KeyEvent .KEY_PRESSED , event -> {
124- if (event .getTarget () instanceof TextInputControl && keyCombination .match (event )) {
125- menuItem .getOnAction ().handle (new ActionEvent ());
126- event .consume ();
127- }
128- });
129- }
13091
13192 /**
13293 * Fills up all the placeholders of this window.
0 commit comments