Re: Text Fields and Truly Centered Text
Posted: Sat Sep 16, 2023 11:46 pm
Hi all
To test, I used Richmond's algorithm (which I think is similar to what Jacque is proposing):
This does indeed center the text vertically, as desired, but try inserting a cursor and/or selecting text:
The method proposed by Bernd that adjusts the topMargin instead (the algorithm is posted above) does not change the cursor size and produces the expected result. This automates what Craig and Klaus were suggesting as a manual adjustment: Everyone will use what they are conformable with, but for me, I cannot have text boxes where the cursor can be several times the size of the text... so I'd go with Bernd's advice.
richmond62 wrote: Fri Sep 15, 2023 6:11 pm What is all the 'guff' about centered text?
...
142 = (half the height of the field) + (half the size of the text)= (256/2) + (28/2)
@Jacque, @RIchmond: Can I point out an issue with using textHeight? It changes the size of the cursor which can make it look ridiculous.jacque wrote: Sat Sep 16, 2023 9:19 pm Turn on fixedLineHeight and set the textHeight to 28. That should be all you need. If you change the text size, you'll need to also adjust the textHeight.
To test, I used Richmond's algorithm (which I think is similar to what Jacque is proposing):
Code: Select all
set the fixedLineHeight of field 1 to true
set the textHeight of field 1 to the height of field 1/2 + the textSize of field 1/2The method proposed by Bernd that adjusts the topMargin instead (the algorithm is posted above) does not change the cursor size and produces the expected result. This automates what Craig and Klaus were suggesting as a manual adjustment: Everyone will use what they are conformable with, but for me, I cannot have text boxes where the cursor can be several times the size of the text... so I'd go with Bernd's advice.