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 placeholder is not aligned correctly with center and right alignment. #18184

Closed
nyenye opened this issue Apr 13, 2018 · 17 comments · Fixed by #18566
Closed

LineEdit placeholder is not aligned correctly with center and right alignment. #18184

nyenye opened this issue Apr 13, 2018 · 17 comments · Fixed by #18566

Comments

@nyenye
Copy link

nyenye commented Apr 13, 2018


Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.


Godot version:
Godot 3.0.2

OS/device including version:
Archlinux

Issue description:
Placeholder on LineEdits is misplaced when alignment is center or right. Shown on image below. Username is Left, Password is Center. When alignment is right, it doesn't show (it probably overflows and clips)

godot_bug

@Calinou
Copy link
Member

Calinou commented Apr 17, 2018

I can reproduce this on commit 59b8166. Pictured below are labels containing text and placeholder text, with left, center and right alignments:

LineEdit alignment issue

@Nolkaloid
Copy link
Contributor

Can reproduce on 3.0.2 stable
image

@akien-mga
Copy link
Member

I'm confused, @Calinou's screenshot seems to show that the bug is the same whether it's a placeholder text or normal text, but @nobelix's screenshot shows only placeholder as buggy.

@nyenye
Copy link
Author

nyenye commented May 2, 2018

@akien-mga For me, it's only placeholders, with v3.0.2.stable.custom_build.

Center:
center
Right:
right
Left:
left

@robfram
Copy link
Contributor

robfram commented May 2, 2018

It's strange, #18095 should have fixed all of this. Could you try the test project attached in #17113?
I will take a look as soon as I can.

@Nolkaloid
Copy link
Contributor

Maybe Calinou meant can't instead of can

@nyenye
Copy link
Author

nyenye commented May 2, 2018

@nobelix Ooh, indeed could be the case.

@robfram I'll try it out and update this comment.

@Calinou
Copy link
Member

Calinou commented May 2, 2018

On my screenshot, all fields have a placeholder defined but only 3 of them have text entered (so the placeholder displays on the other 3).

@robfram
Copy link
Contributor

robfram commented May 2, 2018

Ok, I think I found the problem. It seems to be a problem updating the placeholder position and not calculating it.

TL;DR at end.

Try this steps to confirm all you get the same results as I do:

  1. Create a LineEdit
  2. Set Text to anything (i.e. Testing) (it shows Testing correctly at left position)
  3. Change Alignment to Center (it shows Testing correctly at center position)
  4. Set Text in Placeholder to Placeholder text (no changes are shown, still Testing correctly at center position)
  5. Unset Text deleting the Testing string (it shows Placeholder text bad aligned at center, using the center as the starting point for the text)
  6. Edit Text in Placeholder and simply press Enter to accept the same Placeholder text string as it has (it shows Placehoder text correctly centered)

TL;DR:
For all the LineEdit you have wrong placed, edit the Placeholder/Text property and set it again to force its correct positioning.

Will try to fix this as soon as possible, but feel free to send a PR.

hpvb pushed a commit that referenced this issue May 13, 2018
Editing the `Text` property through the editor causes a wrong
placement of the placeholder, as it calls `LineEdit::clear_internal`,
which was wrongly reseting the cached placeholder width.

Fix #18184.

(cherry picked from commit c17de1f)
malcolmhoward pushed a commit to malcolmhoward/godot that referenced this issue Jul 31, 2018
Editing the `Text` property through the editor causes a wrong
placement of the placeholder, as it calls `LineEdit::clear_internal`,
which was wrongly reseting the cached placeholder width.

Fix godotengine#18184.

(cherry picked from commit c17de1f)
malcolmhoward pushed a commit to malcolmhoward/godot that referenced this issue Jul 31, 2018
Editing the `Text` property through the editor causes a wrong
placement of the placeholder, as it calls `LineEdit::clear_internal`,
which was wrongly reseting the cached placeholder width.

Fix godotengine#18184.
malcolmhoward pushed a commit to malcolmhoward/godot that referenced this issue Jul 31, 2018
Editing the `Text` property through the editor causes a wrong
placement of the placeholder, as it calls `LineEdit::clear_internal`,
which was wrongly reseting the cached placeholder width.

Fix godotengine#18184.

(cherry picked from commit c17de1f)
@leakim34
Copy link

leakim34 commented Aug 8, 2019

Still got this issue on 3.1.1

@akien-mga akien-mga added this to the 3.1 milestone Aug 8, 2019
@FeralBytes
Copy link
Contributor

FeralBytes commented Jun 11, 2020

This is still a problem in Godot 3.2.2-beta4. I request the issue be reopened. Thank you.
image
The font is a dynamic font Black Ops One. The project is hosted here.

@akien-mga akien-mga reopened this Jun 11, 2020
@akien-mga akien-mga modified the milestones: 3.1, 4.0 Jun 11, 2020
@kzerot
Copy link

kzerot commented Oct 5, 2020

Hi there.
Still have same problem, 3.2.3
Bottom one with placeholder.
image

@boleanly
Copy link

boleanly commented Feb 24, 2021

Reporting same problem with 3.2.3 stable and 3.2.4 rc3. Seems like the cached_placeholder_width is not updated when the project is opened in the editor. If anyone needs a quick fix, setting the placeholder_text variable on ready in GDScript fixes the alignment.

There might be other cases of the cached_width / cached_placeholder_width not updating cause I've also encountered regular text being aligned wrong in the editor.

@nathanfranke
Copy link
Contributor

Getting this in 3.3.2.stable

image

Editing the text makes the issue go away, but closing and re-opening the scene makes it screw up again.

@HGCollier
Copy link

HGCollier commented Aug 23, 2021

Currently still present in v3.3.3

C# Fix

public override void _Ready()
{
    PlaceholderText = "Placeholder";
}
public override void _Ready()
{
    GetNode<LineEdit>("LineEditPath").PlaceholderText = "Placeholder";
}

GD Script Fix

func _ready():
    placeholder_text = "Placeholder"
func _ready():
    get_node("LineEditPath").placeholder_text = "Placeholder"

@rainlizard
Copy link
Contributor

rainlizard commented Dec 7, 2021

v3.4

The alignment is screwing up in the editor too when changing the font of a LineEdit. I think this is the same issue as this thread's. The issue occurs in-game as well even though I'm not specifically loading a font, I'm using a custom Theme which has a custom font.

In editor:

  1. Create a long LineEdit (give it 300 pixels width)
  2. Set Text to "abcdefghijklmnopqrstuvwxyz" (something long so the offset is easily visible)
  3. Set Align to "Right" or "Center"
  4. Scroll down to Font (custom_fonts/font) and load a dynamic font that's larger than the default font

This will cause the alignment in the editor to be incorrect, requiring you to edit the text to re-correct the alignment.

This solves my other in-game issue:

func _ready():
	text = text

@akien-mga
Copy link
Member

Fixed by #56837 for 3.5 (was fixed for 4.0 a while ago with a refactor).

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

Successfully merging a pull request may close this issue.