Re: Custom NSViews
Re: Custom NSViews
- Subject: Re: Custom NSViews
- From: Jens Alfke <email@hidden>
- Date: Fri, 06 Jul 2012 17:35:08 -0700
On Jul 6, 2012, at 4:55 PM, William Squires wrote:
> How do I get my ShapeView class (the custom NSView subclass) to have the necessary code/declarations so that IB can see that it can originate an action, just like an NSButton or other control (i.e. Ctrl-drag from the control to the action in the delegate).
I think it would have to subclass NSControl; then IB would let you wire up its target/action properties. This is a bit of a dead-end, though, as it only lets you communicate one thing, i.e. a click on a shape. You're probably going to want something richer.
Another way to do it is to create a 'delegate' or 'target' IBOutlet on your view class that you wire up to the object that will be called when events happen. If you want to be formal about it you can define a protocol in your view's header, and then have the document implement it. This way you can extend that protocol to add methods that will be called in other circumstances.
—Jens
_______________________________________________
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