Re: Return vs Enter
Re: Return vs Enter
- Subject: Re: Return vs Enter
- From: Daniel Jalkut <email@hidden>
- Date: Mon, 07 Nov 2005 11:59:21 -0500
You could examine the virtual key code for the event (-[NSEvent
keyCode]). As far as I know it will always be the same for the Enter
key. From Apple's "iGetKeys.c":
kVirtualEnterKey = 0x04C,
I'm only 99% sure that this is true on all non-Roman keyboards,
though. Does anybody have any cause for concern about relying on this?
Daniel
On Nov 7, 2005, at 11:31 AM, Alan Dail wrote:
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:
sweater.com
This email sent to email@hidden
_______________________________________________
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