Skip to content

Fix text alignment not working with TextFieldWidget #150

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

purebluez
Copy link

I did my testing using TestTile, modifying the TextFieldWidgets at L249 & L254 to have a .setTextAlignment(Alignment.Center).

Before fix
image
Still on the left despite using Alignment.Center

After fix
image
Now centered!!

Copy link
Member

@brachy84 brachy84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it still work properly when the text becomes long so that the scrollbar appears?

@purebluez
Copy link
Author

purebluez commented May 27, 2025

Does it still work properly when the text becomes long so that the scrollbar appears?

No. i cant even enter text longer than the field with the change, somehow didnt pick this up in testing

looking at it further it appears thats because of this check in TextRenderer#wouldFit

if (this.maxWidth < getFontRenderer().getStringWidth(line)) {
    return false;
}

where returning false stops the text from being inserted into the TextField. not sure how to fix this

@purebluez
Copy link
Author

going to mark this pr as draft cuz fixing the issue properly is alot more involved than i thought it would be

@purebluez purebluez marked this pull request as draft May 28, 2025 13:17
@purebluez
Copy link
Author

Unmarking this as draft because testing in game shows everything working and rendering fine even when the field has to scroll

@purebluez purebluez marked this pull request as ready for review May 31, 2025 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants