Skip to content

Commit 0cd815b

Browse files
committed
Use a global menubar on macOS instead of stage-specific menubars(thanks @SwiftWinds)
1 parent 832cb23 commit 0cd815b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/com/airsquared/blobsaver/Controller.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -584,13 +584,14 @@ public void aboutMenuHandler() {
584584
}
585585

586586
private void useMacOSMenuBar() {
587-
587+
// resize stage to account for removed menu bar
588588
((VBox) menuBar.getParent()).setMinHeight(560.0);
589589
((VBox) menuBar.getParent()).setPrefHeight(560.0);
590590
presetVBox.setMinHeight(560.0);
591591
presetVBox.setPrefHeight(560.0);
592592

593-
menuBar.setUseSystemMenuBar(true);
593+
((VBox) menuBar.getParent()).getChildren().remove(menuBar);
594+
594595
MenuBar macOSMenuBar = new MenuBar();
595596
MenuToolkit tk = MenuToolkit.toolkit();
596597

@@ -618,13 +619,13 @@ private void useMacOSMenuBar() {
618619
windowMenu.getItems().add(new SeparatorMenuItem());
619620
windowMenu.getItems().add(tk.createMinimizeMenuItem());
620621
windowMenu.getItems().add(tk.createCycleWindowsItem());
622+
windowMenu.getItems().add(new SeparatorMenuItem());
621623

622624
MenuItem debugLogMenuItem = new MenuItem("Open/Close Debug Log");
623625
debugLogMenuItem.setOnAction(event -> {
624626
debugLogHandler();
625627
tk.setMenuBar(DebugWindow.getDebugStage(), macOSMenuBar);
626628
});
627-
windowMenu.getItems().add(new SeparatorMenuItem());
628629
windowMenu.getItems().add(debugLogMenuItem);
629630

630631
windowMenu.getItems().add(new SeparatorMenuItem());
@@ -647,8 +648,8 @@ private void useMacOSMenuBar() {
647648

648649
macOSMenuBar.getMenus().add(helpMenu);
649650

650-
651-
tk.setMenuBar(primaryStage, macOSMenuBar);
651+
// needs to be run with Platform.runLater(), otherwise the application menu doesn't show up
652+
Platform.runLater(() -> tk.setGlobalMenuBar(macOSMenuBar));
652653
}
653654

654655
public void backgroundSettingsHandler() {

0 commit comments

Comments
 (0)