Adding Objects To Groups
Posted: Tue Jun 09, 2015 10:35 pm
I'd like to add an object to an existing group without ungrouping and regrouping. Any way to do that?
Questions and answers about the LiveCode platform.
https://www.forums.livecode.com/
There are 2000-odd native words in the dictionary. It may not have been obvious that there was such a command as "create", nor that it contains within it the ability to target a group as a destination. As in learning any language, it takes time to get a decent vocabulary. That is why we have this forum...well now I feel silly. I should tried that
dunbarx wrote:Hi all.
There are 2000-odd native words in the dictionary. It may not have been obvious that there was such a command as "create", nor that it contains within it the ability to target a group as a destination. As in learning any language, it takes time to get a decent vocabulary. That is why we have this forum.
Craig Newman
In the Dictionary, for creating new objects see the "create" command, or for copying existing objects into a group see the "copy" command.Not a lot of thought wrote:Ok I'm going to try resurrecting this post. How do you add an object to group using script outside of creating the button within the said group?
To create use "create".Not a lot of thought wrote:I can't just add an object to a group, it must be copied to that group? Wouldn't that then require me to delete the original control?
Code: Select all
Wouldn't that then require me to delete the original control?
Yes we can.but you cannot insinuate a control into a group
Code: Select all
set the relayerGroupedControls to true
Code: Select all
on mouseUp
put the layer of group 1 into tLayerNo -- group layer is always the lowest layer of the group
put the number of controls of group 1 into tControlCount
put tLayerNo + tControlCount into tTopLayer -- layer of group plus the number of the controls of the group is the topLayer within the group
set the relayerGroupedControls to true
set the layer of field "myField" of group 1 to tTopLayer
set the relayerGroupedControls to false
end mouseUp
Code: Select all
on mouseUp
put the layer of group 1 into tLayerNo -- group layer is always the lowest layer of the group
set the relayerGroupedControls to true
set the layer of field "myField" of group 1 to tLayerNo + 1 -- this is the lowest layer within the group
set the relayerGroupedControls to false
end mouseUp
Right.Important! It is not possible for other controls to be interspersed between the controls in a single group, so changing a grouped control's layer may change its group membership if the relayerGroupedControls is true:
* You can move a control out of a group by setting the control's layer to a number greater than the topmost control in the group, or less than the bottom-most control in the group.
* Conversely, you can move a control into a group by setting the control's layer to a number between the bottom-most and topmost controls in the group.