7

当我为 iPhone 开发时,我有多个触摸事件,这对于按钮来说可能是真的。(例如,编辑确实改变了,编辑确实结束了……)

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

怎么做?事件有替代方案吗?

谢谢!

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

4

1 回答 1

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
于 2010-03-01T01:37:54.120 回答