PDA

View Full Version : Setting a Control's Focus?




Fritzables
Jun 22, 2011, 09:39 PM
If I have an app with a number of controls within a window and want a certain control to have Focus when the application first runs - is this done by the First Responder in IB??

Pete



kainjow
Jun 22, 2011, 09:42 PM
In IB, you can drag a connection from your window to a control and select initialFirstResponder. You can do this programmatically via the setInitialFirstResponder: method as well.

There's also makeFirstResponder: which is used at any time to set the focus on a control.

jiminaus
Jun 22, 2011, 09:58 PM
In IB, you can drag a connection from your window to a control and select initialFirstResponder. You can do this programmatically via the setInitialFirstResponder: method as well.

There's also makeFirstResponder: which is used at any time to set the focus on a control.

Just to clarify this is different to the First Responder object in IB. The First Responder placeholder object in IB is used to tie actions to whatever happens to be the First Repsonder at the time. For example, the copy menu item is tied to First Responder so that the copy message goes to whatever has focus at the time.

Fritzables
Jun 22, 2011, 10:33 PM
Thanks Jim,

Yea, I was thinking the First Responder had the control to set focus on controls. You have set me right.... thanks again.

kainjow.... Gee, that was easy..... :D

Thanks for the help guys.

Pete