Center Text From Top To Bottom Of Field.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Center Text From Top To Bottom Of Field.
Hi Guys!!
I have searched the dictionary and can't seem to find a way to center text in a field, between top and bottom of the field (Vertical).
I would greatly welcome any advice on where I should look for in the dictionary!
Many Thanks,
Googie.
I have searched the dictionary and can't seem to find a way to center text in a field, between top and bottom of the field (Vertical).
I would greatly welcome any advice on where I should look for in the dictionary!
Many Thanks,
Googie.
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: Center Text From Top To Bottom Of Field.
Hi,
If I understand you correctly you may use textalign property
Best regards
Jean-Marc
If I understand you correctly you may use textalign property
Code: Select all
set the textalign of fld 1 to center
Jean-Marc
https://alternatic.ch
Re: Center Text From Top To Bottom Of Field.
Isn’t that left-to-right Center alignment?
Not sure there is a built in method for this - other than manipulating textheight or margins… but more than happy to be proven wrong on this!!
Not sure there is a built in method for this - other than manipulating textheight or margins… but more than happy to be proven wrong on this!!
Re: Center Text From Top To Bottom Of Field.
Vertical alignment of text is unfortunately not supported in LC.
As Stam said, you need to play with the margins etc.
As Stam said, you need to play with the margins etc.
Re: Center Text From Top To Bottom Of Field.
There is an old enhancement request from 2005 (!), which may show the priority of this feature...
https://quality.livecode.com/show_bug.cgi?id=2707
https://quality.livecode.com/show_bug.cgi?id=2707
-
- Livecode Opensource Backer
- Posts: 9445
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Center Text From Top To Bottom Of Field.
Sorry, drunk right now, BUT have a look at the fonty bit of the props palette of a text field as somewhere near the bottom there is something with numbers about row spacing that MIGHT be capable of being leveraged.
After a post-prandial snooze will fire up the Mac Mini and try to come up with some pretty pictures and some code.
After a post-prandial snooze will fire up the Mac Mini and try to come up with some pretty pictures and some code.
-
- Livecode Opensource Backer
- Posts: 9445
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Center Text From Top To Bottom Of Field.
There's a lot to be said for gummi-bears: bypassed the snooze . . .
This sort of stuff ONLY works if you ONLY have one line of text:
-
This sort of stuff ONLY works if you ONLY have one line of text:
Code: Select all
on mouseUp
put the ((height of fld "ff")/2) into HITE
set the textHeight of fld "ff" to HITE
end mouseUp
-
- Livecode Opensource Backer
- Posts: 9445
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Center Text From Top To Bottom Of Field.
Well, here's a thought:
- -
-
- -
Code: Select all
on mouseUp
put the textSize of fld "ff" into TextSZ
add 4 to TEXTSZ
put TextSZ
put the number of lines in fld "ff" into NUML
put the height of fld "ff" into HITE
put (HITE/TextSZ) into BZZ
put (BZZ - NUML) into XXX
put TextSZ & "," & XXX
put XXX/2 into XXX2
repeat XXX2 times
put cr before fld "ff"
end repeat
end mouseUp
-
- Livecode Opensource Backer
- Posts: 9445
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Center Text From Top To Bottom Of Field.
The main snag about what I outlined is that that is a once-off script to be applied to a static text
in a field.
Alignment as it is generally understood:
- -
means that as one inserts (types) more text the alignment process is an active thing.
in a field.
Alignment as it is generally understood:
- -
means that as one inserts (types) more text the alignment process is an active thing.
-
- VIP Livecode Opensource Backer
- Posts: 7257
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Center Text From Top To Bottom Of Field.
I'd try getting the formattedHeight of the text, and subtract that from the height of the field, which gives the extra free space available. Divide the free space by 2 and set the top and bottom margins to that number.
Untested, but seems logically sound. If the result is slightly off you may need to account for the text baseline. Adjust the margins by 1/3 of the textheight.
Untested, but seems logically sound. If the result is slightly off you may need to account for the text baseline. Adjust the margins by 1/3 of the textheight.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Livecode Opensource Backer
- Posts: 9445
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Center Text From Top To Bottom Of Field.
Well, its a start.
And, to clarify things, by 'start' I mean that if you add extra text the formatting will go wrong.
- Attachments
-
- Cripes.livecode.zip
- Stack.
- (14.17 KiB) Downloaded 99 times
-
- Livecode Opensource Backer
- Posts: 9445
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Center Text From Top To Bottom Of Field.
OK, OK, OK: here we are . . .
-
-
- Attachments
-
- Vertical alignment.livecode.zip
- Stack.
- (14.57 KiB) Downloaded 106 times