Vertical emplacement

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

dunbarx
VIP Livecode Opensource Backer
Posts: 7713
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Vertical emplacement

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

SparkOut
Posts: 2487
Joined: Sun Sep 23, 2007 4:58 pm

Re: Vertical emplacement

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.

Klaus
Posts: 12356
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Vertical emplacement

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!

jacque
VIP Livecode Opensource Backer
Posts: 6029
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Vertical emplacement

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
Posts: 7713
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Vertical emplacement

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

jacque
VIP Livecode Opensource Backer
Posts: 6029
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Vertical emplacement

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
Posts: 7713
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Vertical emplacement

Jacque.

What is "android"? Is it some Windows outrage?

Stupid, I know.

But are these "Up", "Center" and "Down"?

Craig

jacque
VIP Livecode Opensource Backer
Posts: 6029
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Vertical emplacement

An Android is an intelligent robot...

The native field offers top, middle, and bottom vertical text alignment.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
Posts: 7713
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Vertical emplacement

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

stam
Posts: 420
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Vertical emplacement

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?