Scripting of buttonproducing field to give buttons backgroundBehavior
alex at tweedly.net
Sun Jan 23 10:39:35 EST 2005
Bob Hartley wrote:
> At 01:16 23/01/2005, you wrote:
>> I have met with the problem, that the handler of a field, which shall
>> enable user to produce pre-scripted buttons, is able to produce the
>> buttons with the scripts required, and place them where they shall be
>> placed, - but all attempts to, after "group" "set
>> backgroundBehavior to true" is failing. Best would be, if they could
>> be set to include themselves, as they are produced - now and then-by
>> the user, in one big shared group. Anybody have a solution?
> Ahhh sorry I realise you want to add to a group. I want to do this as
> well so I'll mail you if I get an answer.
> You could use the earlier script I sent to group the objects and also
> add a line to rename the group to "MasterGroup"
> Then use a button to ungroup the group "MasterGroup.
An alternative approach MIGHT be to use the clone command.
If you clone a control which is already part of a group, then it to will
be part of that group. So if there is at least one initial button in the
background group, you could clone it and then modify the name / script
/etc. of the newly created one. Only an option if there is an initial
background group with an initial button.
If you follow Bob's approach of ungrouping and regrouping, you could add
a filter command to allow the option of having other controls which are
not part of the background group (if you need that). Something like
addToGroup "card id 1002", "My Group", "My Button"
on addToGroup pCard, pGroupName, pButton
-- Adds button pButton to the group pGroupName on card pCard
-- assumes controls and groups have unique names
local L, tControls, toDo
repeat with L = 1 to the number of controls of card pCard
put the long name of control L & cr after tControls
filter tControls with ("*of group " & quote & pGroupName & quote & "*")
ungroup group pGroupName of card pCard
put "group " into toDo
repeat with L = 1 to the number of lines in tControls
put word 1 to 2 of line L of tControls & " and " after toDo
put "button" && quote & pButton & quote after toDo
set the name of last group to pGroupName
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.7.1 - Release Date: 19/01/2005
More information about the Use-livecode