• 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
Force an NSTextField to give up focus
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Force an NSTextField to give up focus


  • Subject: Force an NSTextField to give up focus
  • From: Gwynne <email@hidden>
  • Date: Sun, 13 Mar 2005 16:57:04 -0500

I have a window with two NSTextFields and an NSButton. There are no bindings involved, and neither of the fields has a target or action. When the button is activated, I need one of the fields to receive the user focus. I tried [window makeFirstResponder:firstField], but it only worked if the focus was either already on that field or on the button. If the focus was on the second field, there was no effect. I tried all sorts of calls, including -endEditingFor:, -selectNextKeyView:, and all combinations of setting the first responder to the window, nil, and the first field, but nothing worked. Finally, in order to get the second field to give up focus, I had to disable it, call makeFirstResponder for the first field, and re-enable the second field during the next iteration of the run loop.

What am I doing wrong here? The second field has an NSFormatter attached, but the problem continued even when I tried removing the formatter. The Tab key works perfectly. These calls were being made from the action method of the button.

-- Gwynne, key to the Code
Email: email@hidden
Website: http://musicimage.plasticchicken.com/
"This whole world is an asylum for the incurable."

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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: Force an NSTextField to give up focus
      • From: Dan Saul <email@hidden>
    • Re: Force an NSTextField to give up focus
      • From: Stéphane Sudre <email@hidden>
  • Prev by Date: Re: NSPopUpButtonCell in custom NSTableColumn in NSTableView - not changing value
  • Next by Date: Re: Force an NSTextField to give up focus
  • Previous by thread: Re: Tracking rect woes
  • Next by thread: Re: Force an NSTextField to give up focus
  • Index(es):
    • Date
    • Thread