Author Topic: Serious issue with UIInput and tab selection  (Read 1296 times)

zippo227

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
Serious issue with UIInput and tab selection
« on: June 20, 2015, 12:47:59 AM »
It appears that recently support for selectOnTab was removed from UIInput and converted into UIKeyNavigation. This did not work consistently on Password fields for me and resulted in 19 times out of 20, the ui field not being selected. My registration page goes user name, password, email; so this was really bothersome for me. Because you are secretly serializing the selectOnTab field, this was even harder for me. I don't remember setting those tabs, but this is pretty disappointing. I made an alternative script to set up how I need it since UIKeyNavigation does not work properly for Password field. Here it is for anyone who wants to manually override their navigation to support tabs. Remember that if you are having this problem, you must open your scene in a text editor and delete all instances of selectOnTab. ArenMook, I believe you should print out warnings for each time you manually add the UIKeyNavigation for users with the legacy setup.

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. [RequireComponent( typeof(UIInput))]
  5. public class OverrideOnTab : MonoBehaviour
  6. {
  7.     public UIInput selectOnTab;
  8.     private UIInput input;
  9.  
  10.     private bool readyToSelect;
  11.  
  12.     void Awake()
  13.     {
  14.         input = GetComponent<UIInput>();
  15.     }
  16.  
  17.     void Update()
  18.     {
  19.         if (input.isSelected && Input.GetKeyUp(KeyCode.Tab))
  20.         {
  21.             StartCoroutine(SelectAfterUpdate());
  22.         }
  23.     }
  24.  
  25.     IEnumerator SelectAfterUpdate()
  26.     {
  27.         yield return new WaitForEndOfFrame();
  28.         selectOnTab.isSelected = true;
  29.     }
  30.  
  31. }