Skip to content

Commit

Permalink
fix standalone menubar on macOS 14
Browse files Browse the repository at this point in the history
  • Loading branch information
scheffle committed Oct 6, 2023
1 parent fb7060c commit 919bef4
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions vstgui/standalone/source/platform/mac/macapplication.mm
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,15 @@ - (void)setupMainMenu
{
NSMenu* mainMenu = [NSApp mainMenu];
NSMenuItem* appMenuItem = nil;
if (mainMenu == nil)
if (mainMenu == nil || mainMenu.itemArray.count == 1)
{
mainMenu = [NSMenu new];
[NSApp setMainMenu:mainMenu];

appMenuItem = [[NSMenuItem alloc] initWithTitle:@"App" action:nil keyEquivalent:@""];
[mainMenu addItem:appMenuItem];
if (mainMenu == nil)
{
mainMenu = [NSMenu new];
[NSApp setMainMenu:mainMenu];
appMenuItem = [[NSMenuItem alloc] initWithTitle:@"App" action:nil keyEquivalent:@""];
[mainMenu addItem:appMenuItem];
}

NSMenuItem* item =
[[NSMenuItem alloc] initWithTitle:NSLocalizedString (@"Window", "Menu Name")
Expand Down Expand Up @@ -423,14 +425,17 @@ - (void)setupMainMenu
}

// move Windows menu to the end
NSMenuItem* windowsMenuItem =
[mainMenu itemWithTitle:NSLocalizedString (@"Window", "Menu Name")];
[mainMenu removeItem:windowsMenuItem];
[mainMenu addItem:windowsMenuItem];
if (auto* windowsMenuItem = [mainMenu itemWithTitle:NSLocalizedString (@"Window", "Menu Name")])
{
[mainMenu removeItem:windowsMenuItem];
[mainMenu addItem:windowsMenuItem];
}
// move Help menu to the end
NSMenuItem* helpMenuItem = [mainMenu itemWithTitle:NSLocalizedString (@"Help", "Menu Name")];
[mainMenu removeItem:helpMenuItem];
[mainMenu addItem:helpMenuItem];
if (auto* helpMenuItem = [mainMenu itemWithTitle:NSLocalizedString (@"Help", "Menu Name")])
{
[mainMenu removeItem:helpMenuItem];
[mainMenu addItem:helpMenuItem];
}
}

//------------------------------------------------------------------------
Expand Down

0 comments on commit 919bef4

Please sign in to comment.