NSMenuItem and NSPopOver

In an OS X application, which method shows NSPopover when the mouse is above the NSMenuItem (for example, in the spotlight).

Thanks a lot!!! Christopjhe

+4
source share
2 answers

I know it has been a while, but if you still haven't found a solution:

Register your class as NSMenuDelegate in the menu containing NSMenuItem and implement

 - (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item; 

then show popover when calling this method.

+4
source

Can you show your code in the question? That would make it easier for you. But, not knowing what your code looks like, this might work for you:

Add this to your statusItem

 self.statusItem.action = @selector(clickStatusBar:); 

Add a method like this to display a popover

 - (void)clickStatusBar:(id)sender { [[self popover] showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMinYEdge]; } 
-one
source

Source: https://habr.com/ru/post/1394863/


All Articles