NSMenuItem and NSPopOver

后端 未结 2 2123
太阳男子
太阳男子 2021-01-06 08:26

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

2条回答
  •  情书的邮戳
    2021-01-06 08:48

    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];
    }
    

提交回复
热议问题