Making a Label (NSTextField) clickable
Making a Label (NSTextField) clickable
- Subject: Making a Label (NSTextField) clickable
- From: Eric Gorr <email@hidden>
- Date: Tue, 23 Nov 2010 16:00:33 -0500
I just need a Label to send it's action to it's target when I click on it.
The first thing I tried was to use setTarget:, setAction:, & sendActionOn:, but that did not work. I messed around with a couple of other things, but without success.
What did finally work was to subclass NSTextField and make ClickableLabel with a mouseDown: that looked like:
- (void)mouseDown:(NSEvent *)theEvent;
{
if ( [self action] && [self target] )
[self sendAction:[self action] to:[self target]];
}
Not fully satisfied with this solution (I like to avoid subclassing unless absolutely necessary), I was wondering if there was 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