Page 1 of 1

extra space in a field [solved]

Posted: Sat Jan 24, 2015 9:58 pm
by mattmaier
I'm trying to use a field as a container for a short bit of text. I want the edges of the field to shrink down to just enough to show all of the text without any extra padding.

This is the script I'm using to create the field:

Code: Select all

set the loc of the templateField to workingArray[tKey][coord]
   set the textAlign of the templateField to center
   set the margins of the templateField to 5
   set the opaque of the templateField to true
   set the lockText of the templateField to true
   set the threeD of the templateField to false
   set the borderWidth of the templateField to 0
   -- the object has to already exist for some things to work
   create field in group "graphicNetwork" of stack "platyvue"
   put the long name of it into workingArray[tKey][longID]
   set the text of workingArray[tKey][longID] to nodeString(tKey)
   set the width of workingArray[tKey][longID] to the formattedWidth of workingArray[tKey][longID]
   set the height of workingArray[tKey][longID] to the formattedHeight of workingArray[tKey][longID]
And it comes out looking like the field in the picture. The top and left is nice, but every field has a little extra on the right and a lot extra on the bottom.

A related question is that I can't find a property to align the text of a field to the top | center | bottom.

Re: extra space in a field

Posted: Sun Jan 25, 2015 12:58 pm
by keram
Hi mattmaier,
mattmaier wrote:A related question is that I can't find a property to align the text of a field to the top | center | bottom.
I've been also searching for ways to center the text vertically. Have a look here: http://forums.livecode.com/phpBB2/viewt ... =8&t=10817

keram

Re: extra space in a field

Posted: Sun Jan 25, 2015 2:12 pm
by Dixie
Hi...

Try this.. give different values to the 'textheight' and you will notice the text being moved around, set the 'margins' to 0 and then set the height and the width after the field has been created..:-)

Code: Select all

on mouseUp
   set the width of the templatefield to 10
   set the height of the templatefield to 10
   
   set the opaque of the templatefield to true
   set the showfocusborder of the templatefield to false
   set the locktext of the templatefield to true
   set the showborder of the templatefield to false
   set the dontwrap of the templatefield to true
   set the margins of the templatefield to 0
   set the text of the templatefield to "SOME TEXT"
   set the textalign of the templatefield to "left"
   set the font of the templatefield to "helvetica neue"
   set the textstyle of the templatefield to "bold"
   set the textsize of the templatefield to 18
   set the textheight of the templatefield to 31
   set the backgroundcolor of the templatefield to 255,255,0
   set the loc of the templatefield to the loc of this card
   create field
   
   set the width of the last field to the formattedWIdth of the last field
   set the height of the last field to the formattedheight of the last field
end mouseUp

Re: extra space in a field

Posted: Sun Jan 25, 2015 7:06 pm
by mattmaier
Thanks, I found this little nugget of wisdom in that thread:
the formattedHeight of char 1 to - 1 of field 1 means just the text whereas
the formattedHeight of field 1 also includes (besides the text) margins, borderwidth and scrollbars.
Man, there are so many properties, many with overlapping effects, and rarely any clear list of everything that's available.
Anywho, finding out that the formatted of the chars is different from the formatted of the field itself solved my problem for now.