NSTextField eating Escape
site_archiver@lists.apple.com Delivered-To: cocoa-dev@lists.apple.com 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) ___________________________________________________________ Ricky A. Sharp mailto:rsharp@instantinteractive.com Instant Interactive(tm) http://www.instantinteractive.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/site_archiver%40lists.apple... 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. 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. This email sent to site_archiver@lists.apple.com
participants (1)
-
Ricky Sharp