I want to show an NSPopover
from an NSToolbarItem
button in my toolbar.
(i.e. positioned below the button).
Ideally, I want to pass the
Instead of getting the view from the IBAction sender, connect an IBOutlet directly to the toolbar item and use that to get the relative view:
In your header file:
@property (weak) IBOutlet NSToolbarItem *theToolbarItem;
@property (weak) IBOutlet NSPopover *thePopover;
In your implementation file, to show the popover:
[self.thePopover showRelativeToRect:[[self.theToolbarItem view] bounds] ofView:[self.theToolbarItem view] preferredEdge:NSMinYEdge];
This will also work for showing popups from menu item selections inside a toolbar item.