对于NSTextField,没有诸如“编辑确实改变”的事件?
问题描述:
当我为iPhone开发时,我有多个触摸事件,对于一个按钮来说可能是正确的。 (例如,Editing did Change,Editing did End ...)对于NSTextField,没有诸如“编辑确实改变”的事件?
现在我开发的Mac OSX我希望我的应用程序识别NSTextField中的多个事件。
如何做到这一点?有没有其他的事件?
谢谢!
编辑:可能代表是关键?
答
您需要设置一个对象作为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