Custom NSViews
Custom NSViews
- Subject: Custom NSViews
- From: William Squires <email@hidden>
- Date: Fri, 06 Jul 2012 18:55:39 -0500
Okay, I've got my custom NSView subclass to draw my Shape objects (or subclasses thereof). Each Shape inherits or overrides:
-(BOOL)shapeContainsPoint:(CGPoint)thePoint;
Now, I want to detect clicks within the view and iterate over all the objects the view is responsible for, and send them the above message. My Document.h declares:
-(IBAction)didClick:(id)sender;
which - for now - just does an NSLog(). 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).
Furthermore, what's the recommended way to communicate the X,Y position (CGPoint) where the user clicked in the drawable area of the view -> delegate that has the action triggered when the user clicks (i.e. see above)? Should the view hold on to the X,Y location, then provide these are readonly properties which the action code in the delegate can fetch through the (id)sender? Or is there a better way?
_______________________________________________
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