Search Unity

MultiLine Text Area, word wrapping, scrolling, all that jazz

Discussion in 'UI Toolkit' started by BinaryCats, Feb 11, 2020.

  1. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    Hi,

    I want to have a multiline text area which:
    • When the user types the words wrap onto the line below
    • When the user presses enter they start a new line
    • The 'viewport' of the box shifts with the caret to view different lines ( maybe a scroll bar too?)
    Code (UXML):
    1.  
    2.          <engine:Label text="Notes"/>
    3.               <engine:TextField multiline="true" class ="TextArea" name="Notes"/>
    4.         </engine:VisualElement>
    Code (USS):
    1. .TextArea
    2. {
    3.     height:100px;
    4. }
    5. .TextArea > TextInput
    6. {
    7.     -unity-text-align: upper-left;
    8.     white-space:normal;
    9. }
    I have seen other threads on this topic, however they are either dated, or do not give the behaviour I wish. If I recall correctly the above code once worked, however it no longer does.

    The above code does in fact achieve my first two goals, however the view port is always static. i.e. once the user writes enough lines to fill the box, the view port does not shift (looks at original lines) with the caret, and thus the user can not see what they are typing, or view text past the first few lines.

    upload_2020-2-11_12-9-18.png
    How can I resolve this
     
  2. sebastiend-unity

    sebastiend-unity

    Unity Technologies

    Joined:
    Nov 9, 2015
    Posts:
    184
    Sorry for the late response. Try setting "white-space: nowrap" instead.
     
  3. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    On the text input?

    unfortunately that violates "When the user types the words wrap onto the line below" the "this text box does support multilines" is all on one line and does not wrap onto the next line

    upload_2020-2-11_21-56-42.png

    I guess I want wrapping horizontally, but no wrapping vertically
     
  4. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    I have confirmed, what I want to accomplish is what you achieve by using the attribute
    [TextArea(5, 10)]
    attribute on a field, and letting the good ol' imgui
    EditorGUILayout.PropertyField
    render the propertyfield
     
  5. sebastiend-unity

    sebastiend-unity

    Unity Technologies

    Joined:
    Nov 9, 2015
    Posts:
    184
    Sounds to me like a bug then. I'll investigate and get back to you!
     
    BinaryCats likes this.
  6. sebastiend-unity

    sebastiend-unity

    Unity Technologies

    Joined:
    Nov 9, 2015
    Posts:
    184
    Seems like we force a scroll offset of 0 on white-space: normal. A fix should be coming.
     
  7. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    Is there a workaround?
    Do you need me to submit a bug report?
     
  8. sebastiend-unity

    sebastiend-unity

    Unity Technologies

    Joined:
    Nov 9, 2015
    Posts:
    184
    Please do. Unfortunately the forced 0 of the scroll offset value is done in code, probably a legacy fix at the time, so I cannot recommend a workaround right now.
     
  9. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    Bug reported - case 1219402
     
  10. sebastiend-unity

    sebastiend-unity

    Unity Technologies

    Joined:
    Nov 9, 2015
    Posts:
    184
    Thanks. I have a fix which will be added to an upcoming alpha.
     
    BinaryCats likes this.
  11. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    Hello,
    I have noted in my bug report it is marked as closed, I am on unity 2019.3.13 and this bug is still an issue. Should this issue be resolved in this unity version?
     
  12. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    Still not fixed in 2019.4, atleast this combination of selectors/values. Is there something I need to do to get this working?
     
  13. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    The fix now in 2020.2 (alpha). It is not currently scheduled for backport to 2019.4, but that can change.
     
    BinaryCats likes this.
  14. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    Thank you uDamian

    A back port would be very much appreciated. My editor deals with large bodies input by the user. TextArea functionality would be the most ideal layout, without the back port I would have to support two different layouts depending on unity version

    (min version of my plugin is 2019.4)
     
    chatrat12 likes this.
  15. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    I'll do my best to bump priorities but no promises.
     
    chatrat12 and BinaryCats like this.
  16. chatrat12

    chatrat12

    Joined:
    Jan 21, 2015
    Posts:
    122
    Also running into this issue on 2019.4
     
  17. fdp_san

    fdp_san

    Joined:
    Jun 22, 2017
    Posts:
    8
    Long Term Support much, eh ?
    Really makes you wonder if you should use the new tools or wait 5 years til they are mature..

    Do you have any workaround for the time being ?

    Edit :

    Nevermind, I used a property field with a _bindingPath to my textArea property and it worked
    Still, pushing to the adoption of new tech is quite worthless if there is no followup, we're not talking about new things, but bugfixes here.. Though I guess it's a matter of time/money..
     
    Last edited: Feb 9, 2021
    Kerihobo and AnomalusUndrdog like this.
  18. Kerihobo

    Kerihobo

    Joined:
    Jun 26, 2013
    Posts:
    65
    Am running into this issue on 2021.3. Any further news on how the fix went?