NSToolbarItem with custom view in Interface Builder 3 (Leopard)
NSToolbarItem with custom view in Interface Builder 3 (Leopard)
- Subject: NSToolbarItem with custom view in Interface Builder 3 (Leopard)
- From: Gunnar Proppe <email@hidden>
- Date: Sat, 9 May 2009 11:36:00 -0700 (PDT)
I followed the steps described here to set up a toolbar item with a custom view in Interface Builder:
http://developer.apple.com/documentation/Cocoa/Conceptual/Toolbars/Articles/ToolbarInIB.html
Unfortunately my custom view's drawRect is never called. I verified that it does get initialized. The toolbar item's min and max size are set up properly. Just to be safe I had my view conform to NSCoding but initWithCoder and ecodeWithCoder aren't called. I tried various springs and struts settings with no results.
Digging deeper, I subclassed NSToolbarItem and overrode setView and setMinSize so I could break on them. setMinSize is getting called with the correct values. Interestingly, setView gets called before my custom view is initialized. I assume this is the proxy NSView object. Then my custom view is initialized (initWithFrame) but the NSToolbarItem's setView isn't called again with the new view instance. I don't know if this is a bug -- maybe Cocoa does some voodoo in the swapping from the proxy NSView object to the custom view.
Standard views work fine: eg. NSButton and NSBox.
Has anyone successfully used IB to create toolbar items with custom views?
Thanks,
Gunnar
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden