NSMenuBar apps influencing (disabling) each others views (NSMenuItem's) ? BUG

241 views Asked by At

I'm working on a NSMenuBar application and another NSMenuBar app seems to influence the display behaviour of my application!? More precisely: Adobe's Creative Cloud Application. When I click on that (creative cloud) Icon, the popup-view appears. Afterwards, when I click on my StatusBar Icon, my Menu appears, BUT, all the NSMenuItem's that should be Enabled are suddenly Disabled, and not interactive anymore.

Some observations:

When I log the enabled-state of the NSMenuItem, it logs correctly as being Enabled, but it is clearly not displaying as enabled (see screenshot), and clicking on it simply closes the Menu without performing the associated action. I do the logging with the following code:

 -(void)menuWillOpen:(NSMenu *)menu
      {
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC),
           dispatch_get_main_queue(),
           ^{
               NSLog(@"preferences menu-item is enabled: %hhd",[self.preferenceMenuItem isEnabled]);
           });
    }

The NSMenu I use is set to setAutoenablesItems:NO.

Also, Adobe's Creative Cloud uses a popup-view. And when it is opened, It clearly hovers over the screen-real-estate that my NSMenu is using.

When I try to reproduce this with other NSMenuBar applications (e.g. Apple's Wifi or Bluetooth) it all works. No problem. Then again, those applications don't use Popover-views, and they don't completely overlap the space of my app.

Please see these screenshots as illustration:

Before

enter image description here

Malicious Creative Cloud

enter image description here

After

enter image description here

What Am I missing here? Apps should not be influencing each other like this right? I'm slowly but surely losing my mind over this. Any help MUCH appreciated! Thnx!!

1

There are 1 answers

0
user1974507 On

I have found the solution to my own problem. So I hope I will help anybody else struggling with this.

I was using my main xib file menu (with the status-bar) and referenced that menu to open when clicking on the statusbar icon. This caused the app to get in focus and to display two times the same menu (although not open at the same time), one under the statusbar-icon as intended, and one on the left side next to the apple symbol. Whenever the statusbar-menu was somehow getting deactivated, the left menu was still working, as if the focus was shifted to that one. For me the solution was to decouple my referenced menu from the xib's menu, by dragging it outside the parent-menu. It's weird because somehow it's not visible anymore in InterfaceBuilder, but it's definitely still there. See screenshots:

BEFORE:

enter image description here

AFTER:

enter image description here