-
Bug
-
Resolution: Duplicate
-
P4
-
fx2.0.2
-
FX 2.0.2 promoted b03
macos
On Mac if I set an accelerator on a MenuItem that defines a modifier, say ctrl + a, and if I do so using KeyCharacterCombination, as soon as I press the modifier key the handler attached to the action defined for this menu entry is called many times.
That means, as of the code extract below, I see many output lines "menuitem1 got Event" even before I have time to press "a" key.
I should see this output only once and when both ctrl and "a" keys are pressed. At least this is the behavior I get on Windows.
For some reason when using KeyCodeCombination it does as expected on both Mac and Windows.
// KeyCodeCombination acceleratorKeyComboA =
// new KeyCodeCombination(KeyCode.A,
// KeyCombination.CONTROL_DOWN);
KeyCharacterCombination acceleratorKeyComboA =
new KeyCharacterCombination("a",
KeyCombination.CONTROL_DOWN);
MenuItem menuitem1 = new MenuItem();
menuitem1.setText("_Open");
menuitem1.setMnemonicParsing(true);
menuitem1.setAccelerator((KeyCombination) acceleratorKeyComboA);
menuitem1.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
System.out.println("menuitem1 got Event: " + e);
}
});
That means, as of the code extract below, I see many output lines "menuitem1 got Event" even before I have time to press "a" key.
I should see this output only once and when both ctrl and "a" keys are pressed. At least this is the behavior I get on Windows.
For some reason when using KeyCodeCombination it does as expected on both Mac and Windows.
// KeyCodeCombination acceleratorKeyComboA =
// new KeyCodeCombination(KeyCode.A,
// KeyCombination.CONTROL_DOWN);
KeyCharacterCombination acceleratorKeyComboA =
new KeyCharacterCombination("a",
KeyCombination.CONTROL_DOWN);
MenuItem menuitem1 = new MenuItem();
menuitem1.setText("_Open");
menuitem1.setMnemonicParsing(true);
menuitem1.setAccelerator((KeyCombination) acceleratorKeyComboA);
menuitem1.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
System.out.println("menuitem1 got Event: " + e);
}
});