Instead of receiving a view from the IBAction sender, connect the IBOutlet directly to the toolbar item and use this to get a relative view:
In your header file:
@property (weak) IBOutlet NSToolbarItem *theToolbarItem; @property (weak) IBOutlet NSPopover *thePopover;
In your implementation file, to show popover:
[self.thePopover showRelativeToRect:[[self.theToolbarItem view] bounds] ofView:[self.theToolbarItem view] preferredEdge:NSMinYEdge];
This will also work to display pop-ups from menu items in a toolbar item.
Elmer cat
source share