Re: Custom NSViews
Re: Custom NSViews
- Subject: Re: Custom NSViews
- From: William Squires <email@hidden>
- Date: Sat, 07 Jul 2012 08:20:06 -0500
MacOS X (10.6 base SDK)
On Jul 6, 2012, at 7:13 PM, Alex Zavatone wrote:
> iOS or Mac OS?
>
> On Jul 6, 2012, at 7:55 PM, William Squires wrote:
>
>> 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
>
_______________________________________________
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