GUI.FocusControl Manual     Reference     Scripting  
Scripting > Runtime Classes > GUI
GUI.FocusControl

static function FocusControl (name : string) : void

Description

Move keyboard focus to a named control.

See Also: SetNextControlName, GetNameOfFocusedControl.

var username = "username";

function OnGUI () {
// Set the internal name of the textfield
GUI.SetNextControlName ("MyTextField");

// Make the actual text field.
username = GUI.TextField (Rect (10,10,100,20), username);

// If the user presses this button, keyboard focus will move.
if (GUI.Button (Rect (10,40,80,20), "Move Focus"))
GUI.FocusControl ("MyTextField");
}