• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Return vs Enter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Return vs Enter
      • From: Gregory Cooksey <email@hidden>
    • Re: Return vs Enter
      • From: Ricky Sharp <email@hidden>
References: 
 >Return vs Enter (From: Alan Dail <email@hidden>)

  • Prev by Date: Re: Creating a valid XML header?
  • Next by Date: AAC ID3 Tags
  • Previous by thread: Return vs Enter
  • Next by thread: Re: Return vs Enter
  • Index(es):
    • Date
    • Thread