- Home /
UI tab navigation - Please i need something like isfocused but for button
Hello please help me with this, im building a dataentry form in unity, and need navigate between inputfields and buttons using the tab key, objtxt_pass.GetComponent().isFocused //ok objboton_crear.GetComponent(). //isFocused doesnt exist form buttons?, i need any similar to "isfocused" but for button's...... help
command select() work's right whit buttons but why c# or unity dont put a "isfocused" in a button
but im using this code:
public GameObject objtxt_uname;
public GameObject objtxt_pass;
public GameObject salvar_datos;
public GameObject objboton_entrar;
public GameObject objboton_crear;
void Update () {
if (Input.GetKeyDown(KeyCode.Tab)) {
if (objtxt_uname.GetComponent<InputField>().isFocused)
{ objtxt_pass.GetComponent<InputField>().Select();
} else
if (objtxt_pass.GetComponent<InputField>().isFocused)
{ objboton_entrar.GetComponent<Button>().Select();
} else
if (objboton_entrar.GetComponent<Button>(). ) //there is no "is focused"
{ objboton_crear.GetComponent<Button>().Select();
} else
if (objboton_crear.GetComponent<Button>().)
{ objtxt_uname.GetComponent<InputField>().Select();
}
}
sorry for my bad english, im on learning process
Answer by Harinezumi · Feb 13, 2018 at 08:41 AM
Button doesn't have isFocused
(in fact, it seems to be specific to InputField), but you could create custom ISelectHandler like in this example, and set an isFocused
value when it is selected. Then you would need to get your custom component instead of Button, of course.