• 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
NSTextField eating Escape
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextField eating Escape


  • Subject: NSTextField eating Escape
  • From: Ricky Sharp <email@hidden>
  • Date: Fri, 30 Sep 2005 18:48:10 -0500

In my kiosk-type app, I use a completely custom UI (subclasses of NSControl, NSCell, etc.) However, one particular item I could not subclass and get working was NSTextField. But, I was able to use the standard NSTextField for my needs.

For a particular "screen", here's my UI hierarchy:

IIContentWindow (custom NSWindow)
  IIBackground (custom NSView; window background)
    IIGraphic (custom NSView; dialog background)
      NSTextField
      IIButton (custom NSControl/NSActionCell; Cancel)
      IIButton (ditto; OK)

To process key events, I've implemented keyDown: in IIContentWindow. This simply dispatches the event. One of my handlers knows how to deal with Escape and Return/Enter (to simulate clicks on Cancel and Default buttons). In the above hierarchy, IIBackground and IIGraphic cannot become key, and cannot be made the first responder. My button classes are just the opposite.

Now then, whenever the text field has the keyboard focus, Escape does nothing. I've set breakpoints in my window's keyDown:, but that is never hit. It was only reached by some keys (e.g. many of the function keys). Escape, along with many navigational keys such as Home and End did nothing. And, as expected, you could enter text a- ok into the field with all the other keys or input methods.

Since the text field's parent was an IIGraphic, I implemented keyDown: in there; thinking that the key event would be propagated to its parent. It too was never reached when I hit Escape. I tried allowing IIGraphic to become key and become the first responder, but that didn't change the outcome.

Whenever the text field _did not_ have the keyboard focus (possible when full keyboard access is enabled), pressing Escape did the right thing.

I know that a "normal" Cocoa window/dialog does not exhibit this behavior. For example, Safari's "Add Bookmark..." sheet allows Escape to toggle the Cancel button even when the bookmark text field has the keyboard focus.

Is this just a limitation of the framework I have? Why is NSTextField not passing on the key event to my window? If there's no easy solution, I may just punt on this one; my app has only a single NSTextField in it.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.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


  • Follow-Ups:
    • Re: NSTextField eating Escape
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: how to implement equivalent of -[NSTableView _getFullyFormedCellAtColumn:row:]?
  • Next by Date: Re: call selector @"mySelector"
  • Previous by thread: Re: how to implement equivalent of -[NSTableView _getFullyFormedCellAtColumn:row:]?
  • Next by thread: Re: NSTextField eating Escape
  • Index(es):
    • Date
    • Thread