How do i find the "width" of a label?

Hello Thunkers !
Tried this:
SCREEN
But as my label is set to “fit content” it will always show 0 (zero value).
Putting “width” instead of “computed width” will show “fit contents”
Reading Thunkable Docs, i thought that “computed” is ment to fullfill my problem, as it calculate dimension after rendering on screen. But it seems that i lack alot of knowledge about it.

This is just a simplified example of what i need. Actually, i have alot of labels in a column, and i need to find the highest width of collection, to later set all label`s width to that, so my labels will look like a table column. Setting an absolute value to label is not an option for my issue :relaxed:
Any ideeas ?
Thank you.

1 Like

Yes, unfortunately it will give you back the settings that you selected for labels when using Opens event. But you can use a button as a label and you will get the computed width.

[Another way]

Instead of Screen Opens, test your code from a Button Click. When the screen is opening not all objects are defined so you need to give it a time.

2 Likes

I made a quick test to show you the issue.

image

I had this code to show the label width when it has the letter Yes and when it has the sentence This is a test.

The output is not encouraging at all

image

I changed the code to wait a fraction of a second after changing the text of the label. So this is the code
image

and this is the output
image

The 42 in the first trial is actually the size of the label when it has the default word “Label”.

Actually, i set a value to label when screen open only to see that label has value. It has value anyway from the design mode, so was already defined.

Hope that will wok. Ill test right away. Thank you very much.

1 Like

… mmm… ill put wait first to see if it works.

1 Like

This was the right way. Thank you again.

1 Like