Cocoa, getting focused control

Discussion in 'Mac Programming' started by NusuniAdmin, Oct 3, 2004.

  1. macrumors 6502a

    NusuniAdmin

    Joined:
    Nov 19, 2003
    #1
    How would I go about getting the currently focused control? I mean there has to be some method I am missing that will return an identifier for the currently focused control.

    Also is there a method or something that is called each time a control gets focused and loses the focus.


    The reason I am asking is I want some specific things to happen when a control gets its focus and when it loses it.
     
  2. macrumors G3

    iMeowbot

    Joined:
    Aug 30, 2003
    #2
    You can call the window's firstResponder to get a pointer to the object with that status. Is that what you mean?

    This article contains an example; see textObjectToSearchIn
     
  3. thread starter macrumors 6502a

    NusuniAdmin

    Joined:
    Nov 19, 2003
    #3
    this may do what I want, thnx. I will try it out and see how it goes.
     
  4. thread starter macrumors 6502a

    NusuniAdmin

    Joined:
    Nov 19, 2003
    #4
    hmm how come when resignFirstResponder i cannot edit the text in the text field?

    like [self setStringValue:mad:"bla"]; does nothing at all in the resignFirstResponder method.
     

Share This Page