I've created a subclass for NSToolbarItem
and am trying to catch the -(void)mouseDown:(NSEvent *)theEvent
in order to change its state (that's what I added in my subclass as NSToolbarItem
doesn't support states out of the box).
Problem is that the event mouseDown:
is never called, even though I set my toolbar items' class identities in Interface Builder to the one of my new class.
Why is this? NSToolbarItem is related to NSView
, so it should be capable of events no?
NSToolbarItem is a subclass of NSObject, not of NSResponder. The event is never called because it is never supposed to handle any. An NSToolbarItem is like a NSDictionary for an NSToolbar, it stores what it needs to draw.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.