Page 1 of 1
Vertical emplacement
Posted: Fri May 07, 2021 12:13 am
by dunbarx
Wasn't there a property that would "center" text in a field vertically? No fiddling with margins? I think Jacque was involved...
I know I can do this sort of thing with the "formattedHeight".
Craig
Re: Vertical emplacement
Posted: Fri May 07, 2021 7:40 am
by SparkOut
Depending on what you are looking for, iconGravity might be the answer. But you might be asking a different question, as I don't believe this works for fields.
Re: Vertical emplacement
Posted: Fri May 07, 2021 8:26 am
by Klaus
dunbarx wrote: ↑Fri May 07, 2021 12:13 am
Wasn't there a property that would "center" text in a field vertically?
No, Craig, there wasn't!
Re: Vertical emplacement
Posted: Sat May 08, 2021 7:16 pm
by jacque
I see I have saved three methods to do this but they all do rely on margins. Here's what I've got:
Code: Select all
on centerLine -- calculation to get the vertical center of a line of text in a field
constant kLeft = <the left of your box>, <kRight = the right of your box>
put (item 2 of the mouseLoc - the top of fld 1) \
div the lineHeight of fld 1 into tTop
set the rect of grc "box" to kLeft,tTop,kRight,tTop+the lineHeight of fld 1
end centerLine
-----------
To center a block of text in a field, regardless of text size, variable styling, etc.:
put round(the effective textheight of me * .66) into tUnderHang
set the topmargin of me to (the height of me - (the formattedheight of line 1 to -1 of me) + tUnderHang) div 2
-------------
My forum suggestion:
on mouseUp
put the effective textheight of me * .33 into tPadding
put the formattedheight of line 1 to -1 of me into tTotalTextHt
put ( ( the height of me - tTotalTextHt ) / 2) into tTopMargin
set topmargin of me to tTopMargin + tPadding
end mouseUp
I'm sorry I didn't save the authors of the other two methods.
Re: Vertical emplacement
Posted: Mon May 10, 2021 3:11 pm
by dunbarx
Jacque.
Thanks for all that. I used the formattedHeight myself to do the job. I am not sure why I thought there was something similar for vertical to the familiar "center" property for horizontal justification.
Craig
Re: Vertical emplacement
Posted: Mon May 10, 2021 5:29 pm
by jacque
Maybe you saw the docs for the Android native field widget. I was working with it yesterday and noticed it offers 3 different vertical placements.
Unlikely, I know.
Re: Vertical emplacement
Posted: Mon May 10, 2021 7:00 pm
by dunbarx
Jacque.
What is "android"? Is it some Windows outrage?
Stupid, I know.
But are these "Up", "Center" and "Down"?
Craig
Re: Vertical emplacement
Posted: Mon May 10, 2021 7:51 pm
by jacque

An Android is an intelligent robot...
The native field offers top, middle, and bottom vertical text alignment.
Re: Vertical emplacement
Posted: Mon May 10, 2021 8:00 pm
by dunbarx
Jacque.
I begrudgingly admit that the dark side has some cool stuff.
Am I the only one (again) that would love not to have to fiddle with margins and effective/formatted gadgetry to get vertical justification?
Craig
Re: Vertical emplacement
Posted: Tue May 11, 2021 2:20 pm
by stam
Not just the dark side; FileMaker Pro has had this for decades.
However other languages/IDE, for example XOJO do not offer functionality and you have to program it in. I found myself having to do lots of things like that with XOJO which is why i ultimately left it behind for LiveCode which offers many, many conveniences - but this is one convenience that is strangely lacking...
Feature request?