Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug Exception when pressed backspace after selecting all

Discussion in 'UGUI & TextMesh Pro' started by unity_q773grapgv, Nov 17, 2020.

  1. unity_q773grapgv

    unity_q773grapgv

    Joined:
    Nov 17, 2020
    Posts:
    7
    Exception when pressed backspace for removing characters after selected all in TMP Inputfield.
    upload_2020-11-17_15-47-16.png > upload_2020-11-17_15-46-57.png
    Like pictures you can see white space then cause exception.
    It seems that caretPositionInternal is not equal to length of text.

    This happened to both versions 3.0.1 and 3.0.3.


    Code (CSharp):
    1. ArgumentOutOfRangeException: Index and count must refer to a location within the string.
    2. Parameter name: count
    3. System.String.Remove (System.Int32 startIndex, System.Int32 count) (at <fb001e01371b4adca20013e0ac763896>:0)
    4. TMPro.TMP_InputField.Backspace () (at Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime/TMP_InputField.cs:2931)
    5. TMPro.TMP_InputField.KeyPressed (UnityEngine.Event evt) (at Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime/TMP_InputField.cs:1898)
    6. TMPro.TMP_InputField.OnUpdateSelected (UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.textmeshpro@3.0.1/Scripts/Runtime/TMP_InputField.cs:2135)
    7. UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IUpdateSelectedHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2020.1.8f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:99)
    8. UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at C:/Program Files/Unity/Hub/Editor/2020.1.8f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
    9. UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2020.1.8f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:376)
     
    Yooliang likes this.
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    What are the steps to reproduce this behavior?

    What specific text are you first typing in the input field?
     
    Yooliang likes this.
  3. unity_q773grapgv

    unity_q773grapgv

    Joined:
    Nov 17, 2020
    Posts:
    7
    Here are steps to reproduce.
    1. Type "dddd" in input field (whatever few characters as alphabet)
    2. End your input.(focus out input field)
    3. Select again input field then selected all texts.
    4. Type "ㅇ" in input field (ㅇ is korean not O, whatever one character as composition string(ex Korean))
    5. Press backspace keyboard button for removing.
    6. Exception will happen.
     
    Yooliang likes this.
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    I am not able to reproduce the issue so not sure what I am missing from the sequence above.

    I am using the Korean IME (on Windows) and the "ㅇ" is on the D key. Are you using the same key to enter this "ㅇ" character?

    Are you on Windows or Mac?

    P.S. Since it is almost 2:00 am for me, I'll check back in tomorrow and keep trying to reproduce this issue.
     
    Yooliang likes this.
  5. unity_q773grapgv

    unity_q773grapgv

    Joined:
    Nov 17, 2020
    Posts:
    7
    I'm on windows.
    And it's right that "ㅇ" is on the D.
    also, rich text option was enabled.
    reproduce.gif
    I inserted gif image to show reproduce.

    Thanks for checking.

    P.S I found no exception occurred when Allow rich text editing option was enabled. seems to relate with these options.
     
    Last edited: Nov 17, 2020
    Yooliang likes this.
  6. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    I am not able to reproduce the error using the <backspace> key but I am able to reproduce the issue with the <del> key.

    Issue does not occur with Enable Rich Text Editing enabled.

    Can you confirm the issue is when using <del> and not <backspace> or do you get the issue with both?

    P.S. I am using Unity 2020.1.13f1 with TMP version 3.0.3.

    P.S.S. I'll get to work on fixing the <del> issue.
     
  7. unity_q773grapgv

    unity_q773grapgv

    Joined:
    Nov 17, 2020
    Posts:
    7
    As matter of fact, I got the issue when using <backspace> not <del> on windows with Unity 2020.1.8f1.
    But on mac, exception when using <del> on Unity 2020.1.13f1 with TMP version 3.0.3..
    May be It's problem with different keyboard type or different carat position.(case of me, carat was end position.)

    Thanks for working on fixing.
     
  8. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Since I made some changes to IME handling which landed in Unity 2020.1.9f1, can you check if you still get the <backspace> issue in 2020.1.9f1?
     
  9. unity_q773grapgv

    unity_q773grapgv

    Joined:
    Nov 17, 2020
    Posts:
    7
    No exeption in Unity 2020.1.9f1 as you said.
    I can still see white space but works well.
    Thank you.