After you set the view to NSToolbarItem, the target and action of the toolbar item are ignored, so view should trigger the action. Since NSImageView does not handle clicks, you should use NSButton, not:
NSToolbarItem *toolbarItem = [[NSToolbarItem alloc] initWithItemIdentifier:@"someToolbarItem"];
NSButton *button = [NSButton new];
button.image = [[NSBundle mainBundle] imageForResource:@"some_image"];
button.target = self;
button.action = @selector(someAction:);
((NSButtonCell*)button.cell).highlightsBy = NSNoCellMask;
button.bordered = NO;
toolbarItem.view = button;
source
share