Page 1 of 1
Text_Width() Changing
Posted: Fri Nov 20, 2015 12:49 am
by the_wesley_watkins
I am basing the size of a button based off its text width plus 15. However, the button keeps changing size. Can anyone explain to me why this isn't working. Here's a code sample.
Code: Select all
TEXT$ = text$(1)
buttonsize = TEXT_WIDTH(TEXT$) + 15
BUTTON 0 TEXT TEXT$ AT 25, 25 SIZE buttonsize, 25
by the way, the text is not changing. The same is text is being used for every iteration but the button has different sizes every itteration
Re: Text_Width() Changing
Posted: Fri Nov 20, 2015 1:24 am
by Mr. Kibernetik
For me it is not changing...
Re: Text_Width() Changing
Posted: Fri Nov 20, 2015 1:30 am
by the_wesley_watkins
This is the legit code I am using:
Code: Select all
' Label Settings
FILL COLOR w(1,1), w(1,2), w(1,3)
DRAW COLOR 0,0,0
SET BUTTONS FONT NAME labelfont$
SET BUTTONS FONT SIZE 14
label$(categ, 1) = categ$(categ, 1)
label$(categ, 2) = label$(categ, 1) & 2
TEXT$ = label$(categ, 1)
labelsizex = TEXT_WIDTH(TEXT$) + 16
labelsizey = headerheight * 0.495
labely = (graphdiv(startline) + graphdiv(maxline(categ))) / 2
' Label 1
labelx = (margin/2) - (labelsizex/2)
BUTTON label$(categ, 1) TEXT TEXT$ AT labelx, labely SIZE labelsizex, labelsizey
' Label 2
labelx = ((maxx + (maxx - margin)) / 2) - (labelsizex/2)
BUTTON label$(categ, 2) TEXT TEXT$ AT labelx, labely SIZE labelsizex, labelsizey

- image.png (354.95 KiB) Viewed 1751 times

- image.png (367.75 KiB) Viewed 1751 times

- image.png (366.66 KiB) Viewed 1751 times
Notice how the "Temp" label changes? But it always is the same thing.
Re: Text_Width() Changing
Posted: Fri Nov 20, 2015 1:39 am
by the_wesley_watkins
Nevermind! I forgot text_width is based off draw font size and name. Not button font size and name. Just had to add:
Code: Select all
DRAW FONT SIZE 14
DRAW FONT NAME labelfont$
Everything works now!