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!
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.
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.
Attachments
extra space in field.PNG (1.59 KiB) Viewed 4238 times
Last edited by mattmaier on Sun Jan 25, 2015 7:06 pm, edited 1 time in total.
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..
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
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.