Skip to content

Conversation

purebluez
Copy link
Contributor

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
Contributor 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
Contributor 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
Contributor 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
# Conflicts:
#	src/main/java/com/cleanroommc/modularui/test/TestTile.java
#	src/main/java/com/cleanroommc/modularui/widgets/textfield/TextFieldWidget.java
@brachy84 brachy84 merged commit 35d0b44 into CleanroomMC:master Sep 30, 2025
brachy84 added a commit to brachy84/ModularUI2-GTNH that referenced this pull request Sep 30, 2025
* do the fix

* add test

* horizontal

* fix a few bugs

* comment & bool for checking width

---------

Co-authored-by: brachy84 <brachy84@gmail.com>
(cherry picked from commit 35d0b44)
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