NSMenuItem and NSPopOver

安稳与你 提交于 2019-11-30 18:02:23

问题


On OS X app, what is the technique to show a NSPopover when the mouse is over a NSMenuItem (like in spotlight for example).

Thanks a lot!!! Christopjhe


回答1:


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

Register your class as a NSMenuDelegate to the menu that contains the NSMenuItem, and implement

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

then show the popover when this method is called.




回答2:


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

Add this to your statusItem

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

Add method similar to this to make the popover appear

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


来源:https://stackoverflow.com/questions/9149675/nsmenuitem-and-nspopover

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!