Text vertical alignment
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Text vertical alignment
Hi Marek,
I was only joking when I said: "glad you asked". Although I did not want to let the formula unexplained and it is always a good idea to understand what is going on.
Regarding the datagrid: I only have used it once or twice to test it and I had no real need for it. So I am not in a position to give you advice on that.
It may be a good idea to open a new thread with your datagrid question.
Kind regards
Bernd
I was only joking when I said: "glad you asked". Although I did not want to let the formula unexplained and it is always a good idea to understand what is going on.
Regarding the datagrid: I only have used it once or twice to test it and I had no real need for it. So I am not in a position to give you advice on that.
It may be a good idea to open a new thread with your datagrid question.
Kind regards
Bernd
Re: Text vertical alignment
Thanks Mark,
although a little off the track it can be handy in rare circumstances. Like when you want to position a graphic with a gradient as an alternating line background for a list field or table field... But that gets really weird by then.
http://berndniggemann.on-rev.com/altern ... vecode.zip
Kind regards
Bernd
although a little off the track it can be handy in rare circumstances. Like when you want to position a graphic with a gradient as an alternating line background for a list field or table field... But that gets really weird by then.
http://berndniggemann.on-rev.com/altern ... vecode.zip
Kind regards
Bernd
Re: Text vertical alignment
Thanks Berndt for sample stack.
Marek
Marek
Re: Text vertical alignment
Hey Bernd why does
give a different result than
On a related note, in my own investigations I have found that 6 + 2/3 (6.6666666666666666666) is the magic number.
Subtracting it from a multiple of the text size yields reliable vertical positioning results. I painstakingly measured the pixels and drew graphs to discover this.
Code: Select all
put the formattedHeight of char 1 to -1 of field 1 into tVariable
Code: Select all
put the formattedHeight of field 1 into tVariable
Subtracting it from a multiple of the text size yields reliable vertical positioning results. I painstakingly measured the pixels and drew graphs to discover this.
Re: Text vertical alignment
Hi nlexa,
the formattedHeight of field 1 also includes (besides the text) margins, borderwidth and scrollbars.
as for the formattedHeight of a field I attach a little stack, attention it could make you dizzy, use at your own risk...
Kind regards
Bernd
the formattedHeight of char 1 to - 1 of field 1 means just the text whereaswhy does
put the formattedHeight of char 1 to -1 of field 1 into tVariable
give a different result than
put the formattedHeight of field 1 into tVariable
the formattedHeight of field 1 also includes (besides the text) margins, borderwidth and scrollbars.
could you post a sample script or better a sample stack?On a related note, in my own investigations I have found that 6 + 2/3 (6.6666666666666666666) is the magic number.
Subtracting it from a multiple of the text size yields reliable vertical positioning results
as for the formattedHeight of a field I attach a little stack, attention it could make you dizzy, use at your own risk...

Kind regards
Bernd
Re: Text vertical alignment
Nice stack Bernd
Here is an example stack for you. You will notice when you turn off the correction and make the margins 0 that as you decrease the text size it starts disappearing into the top of the field as per normal.
If you use the right ratio (multiplier) applied to the text size and subtract 20/3 (the magic number) and subtract all of this from your margins (which at smaller sizes is addition, minus a minus) you get the text to stay the same distance from the top as it does from the left as dictated by the margin value.
I'm sure the stack and the code will better explain what I'm getting at.
Kind regards
nlexa
Here is an example stack for you. You will notice when you turn off the correction and make the margins 0 that as you decrease the text size it starts disappearing into the top of the field as per normal.
If you use the right ratio (multiplier) applied to the text size and subtract 20/3 (the magic number) and subtract all of this from your margins (which at smaller sizes is addition, minus a minus) you get the text to stay the same distance from the top as it does from the left as dictated by the margin value.
I'm sure the stack and the code will better explain what I'm getting at.
Kind regards
nlexa
Perfect Top Margin
I'm not much of a programmer and more of a graphic designer so trying to get the text to line up correctly was really starting to wind me up


Re: Text vertical alignment
Hi nlexa,
thanks for the two stacks, very nifty, now with the seocnd stack I understand better what you are after.
Kind regards
Bernd
thanks for the two stacks, very nifty, now with the seocnd stack I understand better what you are after.
Kind regards
Bernd
Re: Text vertical alignment
Ender...
nice solution !
Dixie
nice solution !
Dixie
Re: Text vertical alignment
Thanks Dixie.
It wasn't perfect as many pointed it out.
This kinda things can hardly be handled with a single line of code.
Besides, I was a total novice back then; posting a solution was a bold move
Best,
~ Ender Nafi
It wasn't perfect as many pointed it out.
This kinda things can hardly be handled with a single line of code.
Besides, I was a total novice back then; posting a solution was a bold move

Best,
~ Ender Nafi
~... together, we're smarter ...~
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: Text vertical alignment
Thanks Bernd
That slight amount 'off' I was getting was driving me potty (and it would drive my client - who is VERY interested in details - bananas)
Nice work
That slight amount 'off' I was getting was driving me potty (and it would drive my client - who is VERY interested in details - bananas)
Nice work

"...this is not the code you are looking for..."
Re: Text vertical alignment
Dave,
thank you. I am glad it helped.
you said:
http://www.theregister.co.uk/2007/08/31 ... a_ripener/
where a company was looking for an
Kind regards
Bernd
thank you. I am glad it helped.
you said:
reminds me of a hilarious (IMHO) reader comment on "The Register" to this article(and it would drive my client - who is VERY interested in details - bananas
http://www.theregister.co.uk/2007/08/31 ... a_ripener/
where a company was looking for an
The reader comment:Trainee Assistant Banana Ripener
Well I got carried away a bit, I am afraid.Poor industrial relations
I used to have this job! Terrible workplace culture, the forklift operators drove me bananas...

Kind regards
Bernd
-
- VIP Livecode Opensource Backer
- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
- Contact:
Re: Text vertical alignment
Um thanks for the story Bernd - I've thought more about bananas in the last five minutes than I ever have before...
"...this is not the code you are looking for..."