PDA

View Full Version : Cocoa, getting focused control




NusuniAdmin
Oct 3, 2004, 01:21 PM
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.



iMeowbot
Oct 3, 2004, 03:03 PM
You can call the window's firstResponder to get a pointer to the object with that status. Is that what you mean?

This article (http://www.stone.com/The_Cocoa_Files/Doing_Objects_Right.html) contains an example; see textObjectToSearchIn

NusuniAdmin
Oct 3, 2004, 03:50 PM
this may do what I want, thnx. I will try it out and see how it goes.

NusuniAdmin
Oct 3, 2004, 07:37 PM
hmm how come when resignFirstResponder i cannot edit the text in the text field?

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