Page 1 of 3
Text vertical alignment
Posted: Sat Jan 21, 2012 3:22 pm
by snm
I can find only horizontal alignment of text in fields or buttons properties. Is it possible to vertically align it in LC?
snm
Re: Text vertical alignment
Posted: Sat Jan 21, 2012 7:58 pm
by dunbarx
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
Re: Text vertical alignment
Posted: Sun Jan 22, 2012 2:01 am
by snm
Vertical allignment means top, buttom, center
Regards snm
Re: Text vertical alignment
Posted: Sun Jan 22, 2012 7:25 am
by dunbarx
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
Re: Text vertical alignment
Posted: Sun Jan 22, 2012 2:35 pm
by Klaus
Hi snm,
snm wrote:Vertical allignment means top, buttom, center
Regards snm
sorry, no vertical alignment in LiveCode fields!
Best
Klaus
Re: Text vertical alignment
Posted: Sun Jan 22, 2012 5:59 pm
by gpb01
snm wrote:Vertical allignment means top, buttom, center
Regards snm
Not in this way, but for text fields ...
... under "Align" you have "
Margins" ... try to play with this value
Guglielmo
Re: Text vertical alignment
Posted: Sun Jun 24, 2012 5:58 am
by endernafi
How about doing the vertical alignment dynamically, i.e. by script:
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)
Re: Text vertical alignment
Posted: Sun Jun 24, 2012 3:27 pm
by Mark
Actually, Guglielmo's answer is the correct answer.
"endernafi's" answer makes no sense.
Kind regards,
Mark
Re: Text vertical alignment
Posted: Sun Jun 24, 2012 3:38 pm
by endernafi
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
Re: Text vertical alignment
Posted: Sun Jun 24, 2012 3:57 pm
by Mark
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
Re: Text vertical alignment
Posted: Sun Jun 24, 2012 4:06 pm
by endernafi
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,
Re: Text vertical alignment
Posted: Sun Jun 24, 2012 4:37 pm
by Mark
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
Re: Text vertical alignment
Posted: Sun Jun 24, 2012 7:32 pm
by jacque
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.
Re: Text vertical alignment
Posted: Sun Jun 24, 2012 7:46 pm
by Mark
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
Re: Text vertical alignment
Posted: Sun Jun 24, 2012 8:09 pm
by jacque
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.