How do I attach a event to a NSTextField for when I click on it? Are there any examples out there?
NSClickGestureRecognizer *click = [[NSClickGestureRecognizer alloc] initWithTarget:self action:@selector(myTextFieldClicked:)];
[self.myTextField addGestureRecognizer:click];
You can try this: It works for me.
@interface customTextField : NSTextField
@property (strong) id target;
@end
@implementation customTextField
- (void)mouseDown:(NSEvent *)theEvent
{
[self sendAction:@selector(clickAction:) to:[self target]];
}
@end
Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With