2023-03-24 12:52 AM
The new version of TouchGFX (V4.21.0, V4.21.1) displays the text of a Button With Label no more vertical centered. In the designer the text is shown correctly, but in the simulator and in the compiled controller application it is positioned too high.
Is there a way to correct the position?
Screenshot with TouchGFX 4.20.0
Screenshot with TouchGFX 4.21.1
Solved! Go to Solution.
2023-03-24 03:51 AM
Hello @stst9191,
We modified the way we position the text inside the Button with Label between v.4.20.0 and v.4.21.0.
We did those changes to reposition the label text if the font includes a character that goes lower that the font baseline, for example "g".
If you want to get the same behavior as before, you can modify the updateTextPosition() inside the touchgfx\framework\include\touchgfx\widgets\ButtonWithLabel.hpp file inside your project.
You can modify text height spacing by replacing getHeight() by getMaxTextHeight(), like this :
Also, since getMaxTextHeight() is now a deprecated method, you'll also have to remove the deprecation tag inside the touchgfx\framework\include\touchgfx\Font.hpp file :
FYI, we are discussing this internally and considering the fact to add a method or functionality to enable the user to modify the position of the label inside the button by himself.
Hope that helps,
/Yoann
2023-03-24 03:51 AM
Hello @stst9191,
We modified the way we position the text inside the Button with Label between v.4.20.0 and v.4.21.0.
We did those changes to reposition the label text if the font includes a character that goes lower that the font baseline, for example "g".
If you want to get the same behavior as before, you can modify the updateTextPosition() inside the touchgfx\framework\include\touchgfx\widgets\ButtonWithLabel.hpp file inside your project.
You can modify text height spacing by replacing getHeight() by getMaxTextHeight(), like this :
Also, since getMaxTextHeight() is now a deprecated method, you'll also have to remove the deprecation tag inside the touchgfx\framework\include\touchgfx\Font.hpp file :
FYI, we are discussing this internally and considering the fact to add a method or functionality to enable the user to modify the position of the label inside the button by himself.
Hope that helps,
/Yoann
2023-03-24 04:21 AM
Hello Yoann,
thank you for your help. I have made your suggested modifications and it works with the same behavior as before (that I prefer in this application).
/Stefan
2024-06-03 11:06 PM
Hi Yoann
Thank you for your answer, that helps. I ran into the exact same situation when upgrading from 4.20 to 4.23.2. Are there any plans to make this configurable (or even automated) in the future? Like the OP already stated the pre-4.21.1 is the preferred solution e.g. in case there's only capital letters or numbers.
Thanks,
Lukas