Page 1 of 2

Set button width to the width of its label?

Posted: Fri Apr 24, 2015 2:02 pm
by trenatos
I'm programmatically creating buttons, but I can't figure out how to set the width of the button to the width of its label programmatically.

How do I get the width of a buttons label?

Re: Set button width to the width of its label?

Posted: Fri Apr 24, 2015 2:04 pm
by trenatos
Hah, I just found it..

set the width of btn "btnName" to the formattedWidth of btn "btnName"

Re: Set button width to the width of its label?

Posted: Thu Nov 30, 2017 9:53 pm
by bogs
I know, older thread that was answered by the OP no less. But I find myself in a similar situation, with a menu button. Even though the button resizes using the above the way I want it to, the 'menu' below it stays the width of the button. Is there a way to have the button one size, and the menu part a different size?

Re: Set button width to the width of its label?

Posted: Thu Nov 30, 2017 10:07 pm
by dunbarx
Bogs.

Not positive, but I believe the actual menu portion of these gadgets are drawn by the OS, not by LC, so I am not sure you can do anything about that. You can always roll your own, of course.

Craig

Re: Set button width to the width of its label?

Posted: Thu Nov 30, 2017 10:45 pm
by bogs
Thanks Craig, I suspect your right, and I very well may wind up doing exactly that since I've already rolled the entire dialog so far :D Of course, if it isn't and someone knows what I'm missing, I'd rather go that route :D

Re: Set button width to the width of its label?

Posted: Fri Dec 01, 2017 5:05 pm
by Klaus
bogs wrote:
Thu Nov 30, 2017 10:45 pm
I suspect your right...
Really? Come on! 8)

Re: Set button width to the width of its label?

Posted: Fri Dec 01, 2017 5:39 pm
by bogs
Klaus wrote:
Fri Dec 01, 2017 5:05 pm
bogs wrote:
Thu Nov 30, 2017 10:45 pm
I suspect your right...
Really? Come on! 8)
Thanks Klaus, I suspect your being gently sarcastic :P (j/k, I am sure he is right).

This is what I am playing with, currently re-creating (without looking at the actual code) a dialog from the original Hc -
Image
and here is what I've come up with -
Image
Anyhoo, I think the problem I was trying to solve actually has 2 components. It looks like Hc used the width of the longest item in the menu, instead of what was in the button, like so -
Image
The problem this leaves for me to resolve is the icon spacing from the text in the button. I'm using of course the icon and text align right for the button, if the space is much larger than needed, the icon gets dramatically farther away from the text and makes it look funny -
Image

These are all cosmetic issues, functionally, the dialog already works as I was looking for it to, but of course the devil is in the details :evil:

Re: Set button width to the width of its label?

Posted: Fri Dec 01, 2017 9:50 pm
by Klaus
bogs wrote:
Fri Dec 01, 2017 5:39 pm
Klaus wrote:
Fri Dec 01, 2017 5:05 pm
bogs wrote:
Thu Nov 30, 2017 10:45 pm
I suspect your right...
Really? Come on! 8)
Thanks Klaus, I suspect your being gently sarcastic :P (j/k, I am sure he is right).
I am just making a bit fun of your wimpy language skills! :D
It is spelled, "you are right" or abbreviated "you're right", isn't it?

"I suspect your right" has a complete different meaning, monsieur! 8)

Re: Set button width to the width of its label?

Posted: Fri Dec 01, 2017 10:33 pm
by bogs
Klaus wrote:
Fri Dec 01, 2017 9:50 pm
I am just making a bit fun of your wimpy language skills! :D
I will gladly pay you Tuesday for a hamburger today!

You are indeed correct sir, my language skills are nearly non existent at this point :lol:

Re: Set button width to the width of its label?

Posted: Wed Dec 06, 2017 8:51 pm
by mwieder
It's Wednesday already. Did Klaus get paid?

...and stop calling me Shirley.

Re: Set button width to the width of its label?

Posted: Wed Dec 06, 2017 9:07 pm
by bogs
mwieder wrote:
Wed Dec 06, 2017 8:51 pm
It's Wednesday already. Did Klaus get paid?
No hamburgers were given to said Wimpy, so no payments were made for said hamburgers :P

Re: Set button width to the width of its label?

Posted: Wed Dec 06, 2017 9:51 pm
by Klaus
No, I did not get paid yet, Ethel! 8)

Took a while until I got the "Wimpy" joke, since there are no Wimpy shops in germany at all and the last one I saw was about 45 years ago in the netherlands, specivo in the city of Arnhem. :D

Re: Set button width to the width of its label?

Posted: Thu Dec 07, 2017 2:34 am
by bogs
Ugh, and here I thought Popeye was universal.
I am wot I am and thats all wot I am, ugh ugh ugh :lol:

Re: Set button width to the width of its label?

Posted: Thu Dec 07, 2017 2:59 am
by mwieder

Re: Set button width to the width of its label?

Posted: Thu Dec 07, 2017 4:18 am
by bogs
Thats the ticket :D