Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextInput rendering of newlines on single-line #7413

Open
ubruhin opened this issue Jan 21, 2025 · 3 comments
Open

TextInput rendering of newlines on single-line #7413

ubruhin opened this issue Jan 21, 2025 · 3 comments
Labels
a:text Text rendering, fonts, Text input (mS,bF) bug Something isn't working need triaging Issue that the owner of the area still need to triage

Comments

@ubruhin
Copy link
Contributor

ubruhin commented Jan 21, 2025

Edit: Rendering of new-lines in a single line TextInput (the default) is not consistent across renderer.
See also description of #7414

Bug Description

The code below produces this output with winit:

Image

Looks as expected. But with the Qt backend:

Image

The linebreak is ignored.

Reproducible Code (if applicable)

export component AppWindow inherits Window {
    width: 200px;
    height: 200px;

    TextInput {
        wrap: word-wrap;
        text: "Foo\nBar";
    }
}

Environment Details

  • Slint Version: 1.9.2
  • Platform/OS: Ubuntu 22.04, X11
  • Backend/Renderer: Qt

Product Impact

Use-case in LibrePCB (not a blocker for now):

Image

@ubruhin ubruhin added bug Something isn't working need triaging Issue that the owner of the area still need to triage labels Jan 21, 2025
@ubruhin ubruhin changed the title Qt backend: TextInput does not render manual linebreaks Qt backend: TextInput does not render manual newlines Jan 21, 2025
@ogoffart ogoffart added a:backend-qt The Qt backend - including the qt style (mO,bS) priority:high Important issue that needs to be fixed before the next release a:text Text rendering, fonts, Text input (mS,bF) and removed need triaging Issue that the owner of the area still need to triage a:backend-qt The Qt backend - including the qt style (mO,bS) priority:high Important issue that needs to be fixed before the next release labels Jan 21, 2025
@ogoffart
Copy link
Member

The thing is that single-line property defaults to true.
If you add single-line:false; property, it renders correctly with all backend.

Now the question is what to do for slingle-line:true (the default) and our renderer render differently.

With wrap: word-wrap;

Image

Without wrap: word-wrap;

Image

IMHO, word-wrap for a sigle-line edit doesn't make sense.
But what should the \n character do in such case? Qt Just remove it, I think it might make sense.

@ogoffart ogoffart added the need triaging Issue that the owner of the area still need to triage label Jan 21, 2025
@ogoffart ogoffart changed the title Qt backend: TextInput does not render manual newlines TextInput rendering of newlines on single-line Jan 21, 2025
@ogoffart ogoffart marked this as a duplicate of #7414 Jan 21, 2025
@ubruhin
Copy link
Contributor Author

ubruhin commented Jan 21, 2025

Ahh here the problem comes from! That's totally unexpected but now the strange behavior makes more sense.

But to be honest, now I really wonder if it is a good idea to set single-line: true by default? Given the absolute basic use-case where only text specified, I'd really expect the text gets rendered the most basic way, namely the way it is specified.

IMHO, word-wrap for a sigle-line edit doesn't make sense.

Agree. No strong opinion about it, but probably I'd just give single-line priority (if specified, ignore word-wrap) 🤔

@ogoffart
Copy link
Member

But to be honest, now I really wonder if it is a good idea to set single-line: true by default?

I agree. I think it has been the default because at the beginning of the project the component only existed for LineEdit and was only for single line. Then when we added support for TextEdit, we didn't want to break compatibility. And we didn't review that decision later with breaking versions.
Not sure what we can do now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:text Text rendering, fonts, Text input (mS,bF) bug Something isn't working need triaging Issue that the owner of the area still need to triage
Projects
None yet
Development

No branches or pull requests

2 participants