• 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: Accepting and Responding to Keystrokes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accepting and Responding to Keystrokes


  • Subject: Re: Accepting and Responding to Keystrokes
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 21 Jan 2010 16:35:19 -0800

On Jan 20, 2010, at 8:30 PM, Evan Schoenberg wrote:

> I copied the keyDown method from Cocoa in a Nutshell, by the way. Needless to say, I don't really understand it.  Basically, I would love it if somebody could help me to get this program to work, because as of yet I have not gotten anything to respond to keystrokes.  I believe that I need to make Input the First Responder, but I'm not sure about that and I don't know how to anyway...

You also need to tell Cocoa that your view can accept keyboard focus:

- (BOOL)canBecomeKeyView {
	return YES;
}

And in your nib you want to wire the window's "initialKeyView" outlet to your view, so it'll be key by default.

Finally, The keyDown: method increases the length value, but it doesn't trigger a redraw of the view so this won't have any visible effect. After increasing length you need to call
	[self setNeedsDisplay: YES];
which tells the window that your view should be redrawn ASAP.

—Jens

_______________________________________________

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: 
 >Accepting and Responding to Keystrokes (From: Evan Schoenberg <email@hidden>)

  • Prev by Date: Re: NSRulerView and inches
  • Next by Date: Re: NSRulerView and inches
  • Previous by thread: Accepting and Responding to Keystrokes
  • Next by thread: CALayer resizing puzzle
  • Index(es):
    • Date
    • Thread