extra space in a field [solved]

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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
mattmaier
Posts: 109
Joined: Fri Apr 19, 2013 2:49 am

extra space in a field [solved]

Post by mattmaier » Sat Jan 24, 2015 9:58 pm

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

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: extra space in a field

Post by keram » Sun Jan 25, 2015 12:58 pm

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
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: extra space in a field

Post by Dixie » Sun Jan 25, 2015 2:12 pm

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
Attachments
words1.livecode.zip
(1.08 KiB) Downloaded 145 times

mattmaier
Posts: 109
Joined: Fri Apr 19, 2013 2:49 am

Re: extra space in a field

Post by mattmaier » Sun Jan 25, 2015 7:06 pm

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.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”