Return vs Enter
Return vs Enter
- Subject: Return vs Enter
- From: Alan Dail <email@hidden>
- Date: Mon, 7 Nov 2005 11:31:17 -0500
In dialogs with text fields, I want the return key to allow the user
to put carriage returns in the text, but want the enter key to
dismiss the dialog. I have code that looked like it was doing it for me
- (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)
aSelector
{
if (aSelector == @selector(insertNewline:))
{
NSEvent* event = [NSApp currentEvent];
if ([event modifierFlags] & NSNumericPadKeyMask) // test for enter key
{
[[NSApplication sharedApplication] stopModalWithCode:NSOKButton];
return YES;
}
}
return NO;
}
However, the code isn't working on a powerbook - the powerbook
doesn't consider the enter key to be part of the numeric keypad. Is
there a better way to determine that the enter key has been hit in
cocoa? I can't find anything in the documentation. Carbon supports
differentiation between the two keys for just this reason.
Alan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden