Grouping checkboxes with label fields
Sivakatirswami
katir at hindu.org
Mon Sep 13 23:39:26 EDT 2010
To ask the obvious first: we assume you need, in many cases, two
lines worth of label for the check box buttons but RunRev does not allow
multi-line labels for check buttons.
There are many ways to tackle this but if it were me I would add a
custom property to each of the buttons with the full text that I wanted
to associate with that button, name it something like uMyLabel
Then your code could be:
on mouseUp
put the number of buttons of me into nbr
repeat with n = 1 to nbr
if (the hilite of button n of me then)
put (the uMyLabel of button n of me)& ", " after theList
end if
end repeat
delete char -2 to -1 of theList
put theList into field "list"
end mouseUp
but then you have the issue of maintenance. What if you want to change the text of the button label? you have to fix the label and the custom property.
Another solution could be to make your UI consistent.. and not use custom props. You would programatically generate a label field that holds two lines and place that next to each check box button and name it with a hook to the button, then turn off the name and label of all the buttons. ( I don't know if your GUI has space for single line label button to occupy the same vertical space as 2 liners)
First, go ahead and enter the full label text property of all your buttons, don't worry about the space requirement on the GUI level for now. You just want all your data for the same type of object, all in the same "targetable" location.
Next make a label field with all the properties you want them all to have. of course it will be set to wrap and align right, nice background color, text color etc...whatever you want
then have a "tools" button on your UI that you can hide later.
on mouseUp
set the properties of templateField to the properties of fld "MyButtonLabel"
repeat with x = 1 to the number of buttons of this card
put ("Label_"& the short name of button x) into tLabelName
create field tLabelName
set the topright of fld tLabelName to (item 1 of (the topleft of button x)-4,item 2 of the topleft of button x)
# you can move them later or work out the math here to place them correctly
put the label of button x into fld tLabelName
# turn off the label on the button itself
set the showname of btn x to false
# Let's now let's make the check boxes small so they are only as wide as the actual check box itself
# but this will cause the position to change so we need to get the left first.
put the left of btn x into tLeft
set the width of btn x to 20
set the left of btn x to tLeft # restore position
end Repeat
reset templateField
end mouseUp
Then you get your list like this:
on mouseUp
put the number of buttons of me into nbr
repeat with n = 1 to nbr
if (the hilite of button n of me then)
put (the Label of button n of me)& ", " after theList
end if
end repeat
delete char -2 to -1 of theList
put theList into field "list"
end mouseUp
For maintenance you could have a handler in your tools button to update button labels when you change/edit the GUI..
on mouseUp
put the number of buttons of me into nbr
repeat with n = 1 to nbr
set the label of button n of me to fld ("Label_"& the short name of button x)
end repeat
end mouseUp
many ways to tackle it.
Next, since you need to see this in the UI I would programattically
generate a small transparent field over each of the buttons just to the
right of the check box and set the check box to for consistency
On 9/13/10 3:25 PM, charles61 wrote:
> I have a series of cards that have checkboxes. Some of the checkboxes have
> labels fields under them because the label of the checkbox will not hold the
> content of the information displayed. Here is my question: I want to modify
> the following group script for checkboxes to display the content of the
> checkboxes plus the label fields for some of the checkboxes. I have tried
> grouping the checkboxes that have an additional label fields but that does
> not work.
>
> What changes would I need to make this work both checkboxes that have label
> fields and those that do not have label fields?
>
>
> on mouseUp
> put the number of buttons of me into nbr
> repeat with n = 1 to nbr
> put the short name of button n of me into tName
> if not the hilite of button n of me then next repeat
> put tName& ", " after theList
> -- put tName& cr after theList
> end repeat
> delete char -2 to -1 of theList
> put theList into field "list"
> end mouseUp
More information about the use-livecode
mailing list