I understand that you use (BOOL)control:(NSControl *)control textView:(NSTextView *)inputfield doCommandBySelector:(SEL)commandSelector to detect the key for NSTextView and NSTextField that the user has pressed like the following.
- (BOOL)control:(NSControl *)control textView:(NSTextView *)inputfield doCommandBySelector:(SEL)commandSelector
{
if(commandSelector == @selector(insertNewline:) )
{
//... a key is down
return YES; // We handled this command; don't pass it on
}
else
{
return NO;
}
}
My question is how you tell under which text field a key is down when you have multiple such controls. I've set a tag like the following to see if a key is down for a particular text field, but it doesn't work.
- (BOOL)control:(NSControl *)control textView:(NSTextView *)inputfield doCommandBySelector:(SEL)commandSelector
{
if ([inputfield tag] == 100)
{
if(commandSelector == @selector(insertNewline:) )
{
//... a key is down
return YES; // We handled this command; don't pass it on
}
else
{
return NO;
}
}
else
{
return NO;
}
}
Thank you for your advice.