对于NSTextField,没有诸如"编辑确实更改"之类的事件?

adr*_*aum 7 macos events xcode objective-c nstextfield

当我为iPhone开发时,我有多个触摸事件,对于按钮来说可能是真的.(例如编辑完成了更改,编辑完成了...)

现在,我为Mac OSX开发,我希望我的应用程序能够识别NSTextField中的多个事件.

怎么做?这些活动还有其他选择吗?

谢谢!

编辑:可能代表是关键吗?

Rob*_*ger 25

您需要将对象设置为您的委托NSTextField.作为NSTextField它的子类NSControl,-controlTextDidChange:如果实现它,它将在您的对象上调用该方法.

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

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

- (void)controlTextDidChange:(NSNotification *)notification
{
    if([notification object] == textField)
    {
        NSLog(@"The contents of the text field changed");
    }
}
@end
Run Code Online (Sandbox Code Playgroud)