Cocoa application menu bar not clickable

前端 未结 3 1321

I\'m building a menu bar in my cocoa application with the following code in the @implementation of my custom application CustomApplication:

<         


        
相关标签:
3条回答
  • 2021-02-09 13:12

    I had this issue and the reason was because my call to [NSApp activateIgnoringOtherApps:YES] was in applicationWillFinishLaunching: instead of applicationDidFinishLaunching:.

    As soon as I moved it, the menubar worked on first-launch.

    0 讨论(0)
  • 2021-02-09 13:27

    Okay, thanks to the remarks of @bhaller I was able to solve my problem.

    I actually transferred my calls to the delegate as follows.

    -(void)applicationWillFinishLaunching:(NSNotification *)aNotification
    {
      [CustomApplication sharedApplication];
      [CustomApplication setUpMenuBar];
      [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
    }
    
    -(void)applicationDidFinishLaunching:(NSNotification *)notification
    {
      [CustomApplication sharedApplication];
    
      [NSApp activateIgnoringOtherApps:YES];
    }
    
    0 讨论(0)
  • 2021-02-09 13:34

    I fixed by removing LSUIElement in Info.plist if the app has a Window and Menu Bar.

    The old solution is that we override this config with [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];, but in Catalina, it doesn't work anymore.

    0 讨论(0)
提交回复
热议问题