• 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: OK on Enter, not Return
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OK on Enter, not Return


  • Subject: Re: OK on Enter, not Return
  • From: Andrew Merenbach <email@hidden>
  • Date: Fri, 06 Jun 2008 12:29:52 -0700

Quoting Douglas Davidson <email@hidden>:


On Jun 6, 2008, at 11:19 AM, Andrew Merenbach wrote:

I believe that you might do some magic with -keyDown: -- I'm sure that someone else will have more knowledge about this -- but bear in mind that the latest-gen MacBooks (of which I have one) do not have separate Return and Enter keys -- just one. (Maybe the fn button changes it, but even if so, users would have to figure that out.) What about making alt-Enter/alt-Return add a newline, while leaving Return and Enter both to do the job of activating the OK button? Hope this helps, even if only a little!

Here is something I wrote on this before:

Here is the normal sequence when a text view receives key events:

NSTextView's keyDown: passes events to interpretKeyEvents:, which is
where they enter key binding and input management.  They come out
either as insertText: or as doCommandBySelector: (see NSResponder.h for
these three methods).

In particular, non-text keys like enter or return will (with the
standard key bindings) end up using doCommandBySelector: to call
methods like insertNewline: on the NSTextView.

If you are using an NSTextView, you should be able to implement the
text view delegate method

- (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)aSelector;

and examine the selector.

If you are using an NSTextField or similar control, you can implement
their delegate method

- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView
doCommandBySelector:(SEL)aSelector;

If you wish to do something different at this point, you might (for
example) look at the current event and ascertain whether it is a key
down and if so, what key it is.

In most cases you don't actually want to intervene at keyDown: time.
That's because keyDown: takes place before all of the key binding and
input management that is necessary in general to make sense of
keystrokes; it would be easy, for example, for you to break input
methods like those used for East Asian text.  One possibility would be
to use a keyDown: override to determine whether a particular keystroke
is enter or return, but not to make any modifications at that point;
instead, you could use that information to set a flag that would later
be used at doCommandBySelector time.

Douglas Davidson

You are right, Douglas, and although I had seen your prior writings (referenced at least twice, I'm sure, in separate discussions), I had not recalled them. My argument about the Return/Enter on MacBook keyboards still seems an issue to me, though.


Cheers,
Andrew
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >OK on Enter, not Return (From: James Walker <email@hidden>)
 >Re: OK on Enter, not Return (From: Andrew Merenbach <email@hidden>)
 >Re: OK on Enter, not Return (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: OK on Enter, not Return
  • Next by Date: [OT] DAQ Plot and Vvidget Workshop At University Of Pittsburgh
  • Previous by thread: Re: OK on Enter, not Return
  • Next by thread: Re: OK on Enter, not Return
  • Index(es):
    • Date
    • Thread