Formattedheight of a button unexpected behaviour
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Formattedheight of a button unexpected behaviour
I have a button whose label is set via script.
Sometimes there is more than one line of text to place.
Like with fields I've tried to set the height to the formattedheigth:
on mouseUp
set the label of button "B" to "first Line" & cr & "Next Line"
set the height of button "B" to the formattedheight of button "B"
end mouseUp
in button "B"
but that just changes the label, no effect on hte height.
Where is my mistake?
Sometimes there is more than one line of text to place.
Like with fields I've tried to set the height to the formattedheigth:
on mouseUp
set the label of button "B" to "first Line" & cr & "Next Line"
set the height of button "B" to the formattedheight of button "B"
end mouseUp
in button "B"
but that just changes the label, no effect on hte height.
Where is my mistake?
Re: Formattedheight of a button unexpected behaviour
I wonder if buttons respond to this sort of thing. They are not mentioned in the dictionary. Certainly fields and certain other controls do. Setting neither the label nor the text of a button to several lines of text will cause setting the formattedText to change anything.
Craig Newman
Craig Newman
Re: Formattedheight of a button unexpected behaviour
That's what stumped me.
The dictionary entry for formattedheight doesn't mention buttons, but the property is listed when I select Object -> Button
The dictionary entry for formattedheight doesn't mention buttons, but the property is listed when I select Object -> Button
Re: Formattedheight of a button unexpected behaviour
To have a formattedHeight property, the text must belong to a field, I believe. It may be a bug, or a limitation of the field type of the button label being just "label" type. A workaround would be to have a hidden field on the card and:
Code: Select all
on mouseUp
set the label of button "B" to "first Line" & cr & "Next Line"
put the label of button "B" into field "hiddenField"
set the height of button "B" to the formattedHeight of field "hiddenField"
end mouseUp
Re: Formattedheight of a button unexpected behaviour
OK, I was wrong. This works for me :
Code: Select all
on mouseUp
set the label of button "B" to "first Line" & cr & "Next Line"
set the height of button "B" to the formattedHeight of button "B"
end mouseUp
Re: Formattedheight of a button unexpected behaviour
Sparkout.
Isn't that the same code that the OP posted?
Craig
Isn't that the same code that the OP posted?
Craig
Re: Formattedheight of a button unexpected behaviour
Yes... So for the OP something is not working as it should, but LC does seem to have a formattedHeight property for buttons.
Re: Formattedheight of a button unexpected behaviour
And now this is getting weirder. Trying again this morning has more issues. Same problem as the OP - to begin with. Testing with the hiddenField workaround changed the height of the button but not to the correct size. Yesterday I know I looked at the text formatting properties of the button to see if there was anything there that would be a factor, but didn't change anything. Then I went back to test with the original code and it worked. If I now put a specific text font and size into the settings, the hidden field method now will resize to the correct size for some fonts and not for others. I haven't hit on a combination to guarantee a correct resize, and I still can't get the plain formattedHeight property of the button to come out right.
Bizarre
Bizarre