views:

189

answers:

1

When I developed for the iPhone I had multiple events on touch that could be true for a button. (e.g. Editing did Change, Editing did End …)

Now that I develop for Mac OSX I want my application to recognize multiple events in a NSTextField.

How to do that? Is there an alternative for the events?

Thanks!

EDIT: May delegates be the key?

+2  A: 

You need to set an object as the delegate of your NSTextField. As NSTextField is a subclass of NSControl, it will call the -controlTextDidChange: method on your object if you implement it.

@interface MyObject : NSObject
{
    IBOutlet NSTextField* textField;
}
@end

@implementation MyObject
- (void)awakeFromNib
{
    [textField setDelegate:self];
}

- (void)controlTextDidChange:(NSNotification *)aNotification
{
    if([notification object] == textField)
    {
        NSLog(@"The contents of the text field changed");
    }
}
@end
Rob Keniger