Text_Width() Changing

Post Reply
the_wesley_watkins
Posts: 42
Joined: Wed Jul 29, 2015 3:53 pm
My devices: Ipad
Iphone

Text_Width() Changing

Post 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

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Text_Width() Changing

Post by Mr. Kibernetik »

For me it is not changing...

the_wesley_watkins
Posts: 42
Joined: Wed Jul 29, 2015 3:53 pm
My devices: Ipad
Iphone

Re: Text_Width() Changing

Post 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
image.png (354.95 KiB) Viewed 1631 times
image.png
image.png (367.75 KiB) Viewed 1631 times
image.png
image.png (366.66 KiB) Viewed 1631 times
Notice how the "Temp" label changes? But it always is the same thing.

the_wesley_watkins
Posts: 42
Joined: Wed Jul 29, 2015 3:53 pm
My devices: Ipad
Iphone

Re: Text_Width() Changing

Post 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!

Post Reply