Surprising little issue
Eric Chatonet
eric.chatonet at sosmartsoftware.com
Sun Nov 26 09:11:30 EST 2006
Scott,
Just one precision:
I have not inserted any error management in the second code:
It's capital of course!
on preOpenCard -- in the stack's script
local tCurCheckBoxStatus
-----
repeat with i = 1 to the number of buttons
switch the style of btn i
case "Menu"
if the uCurStatus of btn i is an integer then set the
menuHistory of btn i to the uCurStatus of btn i
else -- up to you
break
case "CheckBox"
case "RadioButton"
if the uCurStatus of btn i is a boolean then set the hilite of
btn i to the uCurStatus of btn i
else -- up to you
break
case "scale" -- slider
case "progress" -- progress bar
if the uCurStatus of btn i is an integer then set the
thumbPosition of btn i to the uCurStatus of btn i
else -- up to you
end switch
end preOpenCard
Each uCurStatus property will be set appropriately: on menuPick, on
mouseUp, etc. in control's scripts or will be set globally in the
same way as above in a mouseUp handler in the stack's script.
For instance, in a radio button script:
on mouseUp
<statements>
pass mouseUp -- this will allow to trigger the mouseUp event
higher in the hierarchy
end mouseUp
And in the stack's script:
on mouseUp
switch the style of the target -- the control that initiated the
current process
case "Menu"
set the uCurStatus of the target to the menuHistory of the target
break
case "CheckBox"
case "RadioButton"
set the uCurStatus of the target to the hilite of the target
break
case "scale" -- slider
case "progress" -- progress bar
set the uCurStatus of the target to the thumbPosition of the
target
end switch
end mouseUp
Always think of writing the more universal code as you are able :-)
Hope this helps.
Best Regards from Paris,
Eric Chatonet
Le 26 nov. 06 à 14:46, Eric Chatonet a écrit :
> Hi Scott,
>
> That's exactly the same problem :-)
>
> on preOpenCard -- in the stack's script
> local tCurCheckBoxStatus
> -----
> if there is a btn "MyCheckBox" then
> put the uCurCheckBoxStatus of this card into tCurCheckBoxStatus
> if tCurCheckBoxStatus is a boolean then
> set the hilite of btn "MyCheckBox" to tCurCheckBoxStatus
> else set the hilite of btn "MyCheckBox" to true -- or false :-)
> end if
> end preOpenCard
>
> On the other hand:
>
> on mouseUp -- check box script
> <Statements>
> set the uCurCheckBoxStatus of this card to the hilite of me
> end mouseUp
>
> --------------------------------------------
>
> BUT you could prefer write a more "global" code:
>
> on preOpenCard -- in the stack's script
> local tCurCheckBoxStatus
> -----
> repeat with i = 1 to the number of buttons
> switch the style of btn i
> case "Menu"
> set the menuHistory of btn i to the uCurStatus of btn i
> break
> case "CheckBox"
> case "RadioButton"
> set the hilite of btn i to the uCurStatus of btn i
> break
> case "scale" -- slider
> case "progress" -- progress bar
> set the thumbPosition of btn i to the uCurStatus of btn i
> end switch
> end preOpenCard
>
> Etc.
> And each value will be stored in a custom property stored in the
> control itself (not the card)
>
> Actually custom properties are very convenient.
> They did not exist in HC.
> Then many users coming from this environment don't take them into
> consideration :-(
> What a pity :-)
>
> PS. To know the style of any Rev control just create a new stack
> with all kinds of objects and put in the card script: "on mouseUp;
> put the style of the target;end mouseUp ;-)
>
> Best Regards from Paris,
> Eric Chatonet
>
> Le 26 nov. 06 à 14:26, Scott Kane a écrit :
>
>> Eric kindly helped me with the issue of storing a list object in a
>> custom property and it works beautifully (this is a stack with
>> multiple cards with objects set a background groups). I've been
>> trying to do something similar with checkboxes. However I don't
>> seem to be able to get it to stick. Anyone care to share a simple
>> routine to store the checked status of a checkbox as a custom
>> property so that each car can have a boolen result that may be
>> different to another card in that stack?
>>
>> Thanks in advance.
>>
>> Scott
------------------------------------------------------------------------
----------------------
http://www.sosmartsoftware.com/ eric.chatonet at sosmartsoftware.com/
More information about the use-livecode
mailing list