• 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
Return vs Enter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Return vs Enter
      • From: Dirk Stegemann <email@hidden>
    • Re: Return vs Enter
      • From: Daniel Jalkut <email@hidden>
  • Prev by Date: Bind a Quartz Composer composition to a NSImageView image well
  • Next by Date: Re: Creating a valid XML header?
  • Previous by thread: Bind a Quartz Composer composition to a NSImageView image well
  • Next by thread: Re: Return vs Enter
  • Index(es):
    • Date
    • Thread