1
votes

I build a Menu Bar App. When I click on a menu item. Main Window will shows up in the center on the screen. The problem is every first time main window shows up, the top left menus including file, edit, help, etc (including the Apple Icon). It's just frozen.

I can't click on any of the menu items. Until I click other app and then click my app's main window again, the top left menus will be clickable.

My users are not very happy about it, they want me to fix on the next release. Here is the code to show my app's main window.

- (void)showWindow {
      [self.window makeKeyAndOrderFront:self];
      [NSApp activateIgnoringOtherApps:YES];
      [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
 }

Given that self is my App Delegate and window is a instance NSWindow(my main window). A little help here please?

1
See my comment to similar SO question: stackoverflow.com/a/68057340/1418981. Tested and works on macOS 11.Vlad

1 Answers

0
votes

I had the same issue and tried many things. The answer was to add

[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];

into AppDelegate's

applicationWillFinishLaunching

Found the answer from this question Cocoa application menu bar not clickable