I need a Ctrl+Shift+S
accelerator for a menu item. However, the accelerator I created doesn't work. This is my code:
public class NewMain extends Application {
@Override
public void start(Stage stage) {
MenuBar menuBar = new MenuBar();
Menu fileMenu = new Menu("File");
MenuItem fooItem = new MenuItem("Foo");
fooItem.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN));
fooItem.setOnAction(e -> System.out.println("Ctrl+Shift+S triggered"));
MenuItem barItem = new MenuItem("Bar");
barItem.setAccelerator(new KeyCodeCombination(KeyCode.A, KeyCombination.CONTROL_DOWN));
barItem.setOnAction(e -> System.out.println("Ctrl+A triggered"));
fileMenu.getItems().addAll(fooItem, barItem);
menuBar.getMenus().add(fileMenu);
BorderPane root = new BorderPane();
root.setTop(menuBar);
Scene scene = new Scene(root, 400, 300);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
If you run the code you will see that Ctrl+A
works, but Ctrl+Shift+S
doesn't.
Could anyone say how to fix it?