NSTextField SetFocus

Discussion in 'Mac Programming' started by McBgnr, Apr 21, 2009.

  1. McBgnr macrumors regular

    Apr 13, 2009

    I want to set focus on NSTextField programatically.

    I have tried
    [myWindow makeFirstResponder:myTextField];

    Though this is highlighting the text field with a blue border but not showing the carot symbol inside it and I can directly type in words into it.

    How can I get it ready to accept input thru a program?
  2. kainjow Moderator emeritus


    Jun 15, 2000
    This should work. If it has the blue focus ring, that means it's the first responder. I don't think the text cursor will always show right away, but you should be able to start typing. Maybe something else is going on in your code?
  3. McBgnr thread starter macrumors regular

    Apr 13, 2009
    I checked my code again and moved this call to the end of the function. It is working now :)

    Thanks a bunch.

Share This Page