Overlapping text in option button
Ken Ray
kray at sonsothunder.com
Sat May 21 17:27:03 EDT 2005
On 5/21/05 3:21 PM, "Alejandro Tejada" <capellan2000 at yahoo.com> wrote:
> Hi Developers,
>
> I've been working with option buttons
> and noticed that if one line of text
> is largest than the width of the button,
> this text extends over the button,
> overlapping the small triangle at the
> right of the option button.
>
> How could i solve this?
> Is there some property of Option buttons
> that could keep the text of overlapping
> the right of the button?
You can use my "stsEllipsis" handler to truncate and put an ellipsis after
the menu item if it doesn't fit the button. Here's how you use it... put the
"stsEllipsis" handler in your stack script or a library, then simply add a
call to stsEllipsis as the first line in your menuPick handler for the
option button. For more control, you can set a custom property (uMaxSize) of
the option button). Here's an example:
on menuPick pWhat
stsEllipsis pWhat
-- Do what you want to do with pWhat
end menuPick
on stsEllipsis pChoice
if the uMaxSize of the target = "" then
put the width of the target -15 into tW
else
put the uMaxSize of the target into tW
end if
lock screen
-- Get width of ellipsis
set the label of the target to "..."
-- Now work backwards from length of text
set the label of the target to pChoice
put the formattedWidth of the target into tSize
if tSize > tW then
put "" into tLabel
repeat with x = 1 to length(pChoice)
set the label of the target to (char 1 to x of pChoice) & "..."
if the formattedWidth of the target > tW then
exit repeat
else
switch (the platform)
case "MacOS"
put x+1 into tMax
break
case "Win32"
put x+2 into tMax
break
default
put x into tMax
break
end switch
put char 1 to tMax of pChoice & "..." into tLabel
end if
end repeat
set the label of the target to tLabel
end if
unlock screen
end stsEllipsis
Enjoy!
Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com
More information about the use-livecode
mailing list