Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Getting zero-width-space when pressing shift+tab in input field

Discussion in 'UGUI & TextMesh Pro' started by GiantLightStudios, Dec 31, 2021.

  1. GiantLightStudios

    GiantLightStudios

    Joined:
    Jul 24, 2019
    Posts:
    9
    Steps to reproduce:
    • New scene
    • Create -> UI -> Input Field - TextMeshPro
    • Press Play
    • Click on the text field to focus
    • Press shift + tab
    • See the following character in the text field: "" which appears to be the 0x200b zero-width-space character, just visible somehow?
    Environment:
    • Unity 2020.3.22f1 LTS
    • TMP v3.0.6
    • Using the new Unity Input System
    • Mac (haven't tested on windows)
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The child text component is used for text display and formatting. As such, it contains a zero width space added at the end of its text. This is expected behavior.

    When checking the text itself, you should be using the TMP_InputField.text property and not the property of the child text component.

    Having said that, we is your expectation when using shift-tab in the input field?
     
  3. GiantLightStudios

    GiantLightStudios

    Joined:
    Jul 24, 2019
    Posts:
    9
    Thanks for the response! I totally understand about that space existing at the end of the text, but I'm actually seeing a small rectangle appear in the text field. Screenshot attached.

    As for what I expect when using shift-tab, ideally it would auto navigate to a previous input, but I know that it doesn't so have implemented that myself. However, in the screenshot, there are 0 additional scripts or anything interacting with the text field, so it shouldn't be related to that at all. All I want is for hitting shift+tab to not add a visible square outline.

    Thanks again!
     

    Attached Files:

    halley likes this.
  4. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,273
    Same issue still exists in 2022.3.14f1: when implementing the usual Tab / Shift+Tab navigation workarounds, the Tab solution works just fine, but if I press Shift+Tab while there's an InputField, the field's text gets a visible square placeholder (sometimes called mojibake or tofu) for the unprintable character.

    Edit: to be clear, you don't need to implement any navigation workarounds to see this bug. A Shift+TAB will show this result even in stock controls.

    In 2022, I also get this warning:
    The character with Unicode value \u0019 was not found in the [Inter-Regular SDF] font asset or any potential fallbacks. It was replaced by Unicode character \u25A1 in text object [Text].


    The special character is not present in the TMP_InputField's
    .text
    property value; I cannot just copy the
    .text
    and then restore it later, because the copied value has no unprintable character (in my example screenshot, the text typed before Shift+Tab is just 'blah' length 4.
     

    Attached Files:

    Last edited: Dec 5, 2023