Text vertical alignment
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Text vertical alignment
I can find only horizontal alignment of text in fields or buttons properties. Is it possible to vertically align it in LC?
snm
snm
Re: Text vertical alignment
I am missing this. What is horizontal alignment in a text field? I know there is "left", "right" and "center" alignment.
But these are all, essentially, "vertical"
Craig Newman
But these are all, essentially, "vertical"
Craig Newman
Re: Text vertical alignment
Vertical allignment means top, buttom, center
Regards snm
Regards snm
Re: Text vertical alignment
Hmmm.
If I set the alignment of a field to "left", I see this as a 'vertical" thing. The several lines are aligned in this way. But that may be just (mis)interpretation.
What is meant by aligning them horizontally, then? Lines are already essentially horizontal entities. How do you modify this? You don't mean adjust the line spacing (the textHeight), do you?
Craig Newman
If I set the alignment of a field to "left", I see this as a 'vertical" thing. The several lines are aligned in this way. But that may be just (mis)interpretation.
What is meant by aligning them horizontally, then? Lines are already essentially horizontal entities. How do you modify this? You don't mean adjust the line spacing (the textHeight), do you?
Craig Newman
Re: Text vertical alignment
Hi snm,
Best
Klaus
sorry, no vertical alignment in LiveCode fields!snm wrote:Vertical allignment means top, buttom, center
Regards snm
Best
Klaus
Re: Text vertical alignment
Not in this way, but for text fields ...snm wrote:Vertical allignment means top, buttom, center
Regards snm
... under "Align" you have "Margins" ... try to play with this value

Guglielmo
Re: Text vertical alignment
How about doing the vertical alignment dynamically, i.e. by script:
It's a simple script and of course can be developed further.
It's a simple script and of course can be developed further.
Code: Select all
set the topMargin of field theField to \
(round(((the height of field theField - the formattedHeight of field theField)/2)) + the topMargin of field theField)
~... together, we're smarter ...~
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
Re: Text vertical alignment
Actually, Guglielmo's answer is the correct answer.
"endernafi's" answer makes no sense.
Kind regards,
Mark
"endernafi's" answer makes no sense.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Text vertical alignment
I have a piece of code which produces text fields as a list.
The number of these fields is totally random and there are hundreds of them.
In these circumstances how should I play the Margins value manually?
And that piece of code worked like a charm, just this morning, it made a lot of sense for me.
Maybe it's not suitable for every occasion but with a little tweaking it should work.
Simple and easy.
And that snippet plays with Margin values, too, actually.
Best Regards,
Ender Nafi
The number of these fields is totally random and there are hundreds of them.
In these circumstances how should I play the Margins value manually?
And that piece of code worked like a charm, just this morning, it made a lot of sense for me.
Maybe it's not suitable for every occasion but with a little tweaking it should work.
Simple and easy.
And that snippet plays with Margin values, too, actually.
Best Regards,
Ender Nafi
~... together, we're smarter ...~
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
Re: Text vertical alignment
Dear Ender,
You can set the margins by script. Setting the topMargin to a value derived from itself, as you do in the code you posted, doesn't make sense without lots of explanations.
Kind regards,
Mark
You can set the margins by script. Setting the topMargin to a value derived from itself, as you do in the code you posted, doesn't make sense without lots of explanations.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Text vertical alignment
I couldn't get the reason behind, but anyways, you're the guru
It worked as of now for me, thus I did want to share.
Best,

It worked as of now for me, thus I did want to share.
Best,
~... together, we're smarter ...~
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
__________________________________________
macOS Sierra • LiveCode 7 & xCode 8
Re: Text vertical alignment
Hi,
Surely, I appreciate that you share some code and I believe you when you say it works for you. Probably you set the topMargin twice or you can assume a constant value for the value when the script runs for the first time or something else.
Kind regards,
Mark
Surely, I appreciate that you share some code and I believe you when you say it works for you. Probably you set the topMargin twice or you can assume a constant value for the value when the script runs for the first time or something else.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Text vertical alignment
Ender's script makes sense to me.
Subtract the formattedheight of the field from its height --> the available empty vertical space
Divide by 2 --> equalize the amount of space at top and bottom
Add the original topmargin --> retain original top margin
I might leave off the last part, but it still works. It does assume the field height is more than the height of its contents.
Subtract the formattedheight of the field from its height --> the available empty vertical space
Divide by 2 --> equalize the amount of space at top and bottom
Add the original topmargin --> retain original top margin
I might leave off the last part, but it still works. It does assume the field height is more than the height of its contents.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Text vertical alignment
Exactly, Jacque, that's the kind of explanation I meant. I think that your last remark about the assumption is particularly important.
Kind regards,
Mark
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Text vertical alignment
I can't think of any other way to calculate the vertical space. Seems like a functional script to me, and I don't think Ender needs to to feel bad about it. You mentioned a script should set the top margin, and that's what his script does.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com