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

LineEdit cursor is sometimes invisible if 2D scaling is below the native resolution #58133

Closed
brianwinterpixel opened this issue Feb 15, 2022 · 6 comments

Comments

@brianwinterpixel
Copy link
Contributor

brianwinterpixel commented Feb 15, 2022

Godot version

3.4.2.stable

System information

Windows 10, GLES3

Issue description

All text editing controls use a cursor line width of 1 pixel in exported projects. This causes issues when using controls with different scales. This is a common use case when scaling down UI to fit smaller resolution screens.

Example:

This LineEdit has rect_scale=(0.9, 0.9)

At some cursor positions, it is visible:
image
However, in others, it is always invisible:
image

Steps to reproduce

See above

Minimal reproduction project

lineeditScaleBug.zip

@Calinou
Copy link
Member

Calinou commented Feb 15, 2022

Related to #44253.

This can likely be fixed by dividing the caret width by the control's scale if it's lower than 1.0, but this requires querying all the parent Controls for their own scale (which can be slow in complex scene trees).

This causes issues when using controls with different scales. This is a common use case when scaling down UI to fit smaller resolution screens.

Control scaling should only be used for animation purposes, as it breaks down in many situations (input handling, containers, …). Do not rely on Control scaling for multiple resolutions. Use Godot's built-in support for handling multiple resolutions instead, which supports lower-than-native scale factors and specifying a custom scale factor since Godot 3.4.

@Calinou Calinou added this to the 4.0 milestone Feb 15, 2022
@brianwinterpixel
Copy link
Contributor Author

In our project we don't explicitly scale down nodes, but our base resolution is set higher than some platforms we deploy to, resulting in them being scaled down by the engine. So perhaps the issue title/description could be improved.

@Calinou Calinou changed the title LineEdit cursor is sometimes invisible with rect_scale<1 LineEdit cursor is sometimes invisible if 2D scaling is below the native resolution Feb 15, 2022
@Calinou
Copy link
Member

Calinou commented Feb 15, 2022

To my knowledge, this automatic scaling can't be easily detected on the node's size, so I'm not sure what could be done (other than defaulting the caret width to 2).

@jasonwinterpixel
Copy link
Contributor

jasonwinterpixel commented Feb 16, 2022

Potential solution is allowing users to set the caret width in theme properties.

@Calinou
Copy link
Member

Calinou commented Feb 16, 2022

Potential solution is allowing users to set the caret width in theme properties.

This is already done in master, but it wasn't backported to 3.x yet: #54956

Feel free to look into backporting this to 3.x 🙂

@Calinou
Copy link
Member

Calinou commented Jul 21, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants