Search Unity

Textfield in EditorWindow only updates when it loses focus

Discussion in 'Immediate Mode GUI (IMGUI)' started by Aeonvirtual, May 1, 2019.

  1. Aeonvirtual

    Aeonvirtual

    Joined:
    Oct 14, 2015
    Posts:
    33
    I have a textfield that I want to sanitize as the user is typing into it.
    I want to strip out non-letter characters and l want to limit the length.

    I would expect something like this to work but it doesn't:
    Code (CSharp):
    1. string tmp = EditorGUILayout.TextField("ACCESS TOKEN:", accessToken);
    2. tmp = alphaNumeric.Replace(tmp, "");
    3. if (tmp.Length > 6) tmp = tmp.Substring(0, 6);
    4. accessToken = tmp.ToUpper();
    I can still type whatever I want into the textfield and it only updates once the textfield loses focus. Is this a bug?