• 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
Catching Up/Arrow key presses in a text field
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Catching Up/Arrow key presses in a text field


  • Subject: Catching Up/Arrow key presses in a text field
  • From: Harilaos Skiadas <email@hidden>
  • Date: Wed, 15 Sep 2004 22:23:53 -0700 (PDT)

Hello all,

  this is really not a question, but I just figured
out what I now think is the right way to the problem I
had of catching some keyboard events, in particular
the up and down arrow key presses, when they are typed
in a text field, and thought about posting it here, in
the hope that others with a similar problem might
benefit.
What I wanted was to have a method get called when the
user presses the upper key in the text field, and
initially was trying to use keyDown to detect that.
The problem with that (or at least one of the
problems) was that the field editor handles that.
After a lot of searching, I found out that the
delegate of a text field can simply implement the
method control:textView:doCommandBySelector:
and compare the doCommandBySelector against the pretty
long list of actions that can be found in the
documentation for NSResponder, and support lots of
common things one might want to do.
In my particular case, the action moveUp: is called
when the up arrow key is pressed, and similarly
moveDown: when the down arrow key is pressed. One can
similarly catch delete requests I think (but haven't
tried it).
That's all I wanted to say, I just felt this is a
pretty common problem that is not very well documented
(or my search skills are pretty bad). I had seen the
doCommandBySelector "method" elsewhere, but hadn't
fully realized its power.

Cheers,
Haris



_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
 _______________________________________________
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

  • Prev by Date: Using External C Libraries with Objective-C
  • Next by Date: Re: Enabling the Print… menu item for an NSView
  • Previous by thread: External C Libraries and ZeroLink (was: Using External C Libraries with Objective-C)
  • Next by thread: Creating popup button's menu at the last moment
  • Index(es):
    • Date
    • Thread