Page 1 of 1

Adding Objects To Groups

Posted: Tue Jun 09, 2015 10:35 pm
by Not a lot of thought
I'd like to add an object to an existing group without ungrouping and regrouping. Any way to do that?

Re: Adding Objects To Groups

Posted: Tue Jun 09, 2015 10:51 pm
by msellke
It can certainly be done.
There are many ways to do it.
You can use the project browser and drag & drop the object into the required group for one method.
You can also add an object to group via script.

Re: Adding Objects To Groups

Posted: Tue Jun 09, 2015 11:22 pm
by Not a lot of thought
I guess I didn't specify. I need to add it to the group using script from the button creating the object.

Re: Adding Objects To Groups

Posted: Tue Jun 09, 2015 11:34 pm
by msellke
If you want to add it to a group whilst creating the object it's quite simple.
Fore example creating a button in group test using script as per below.

on mouseUp
create button "button_name" in grp "test"
end mouseUp

Re: Adding Objects To Groups

Posted: Tue Jun 09, 2015 11:52 pm
by Not a lot of thought
...well now I feel silly. I should tried that. Thanks!

Re: Adding Objects To Groups

Posted: Wed Jun 10, 2015 3:29 pm
by dunbarx
Hi all.
..well now I feel silly. I should tried that
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

Re: Adding Objects To Groups

Posted: Thu Jun 11, 2015 6:02 pm
by Greg O.
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

That is without a doubt the best response to this type of post I have ever seen. It made me feel better for having similar questions.

Thank you.

Re: Adding Objects To Groups

Posted: Tue Jun 23, 2015 9:51 pm
by Not a lot of thought
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?

Re: Adding Objects To Groups

Posted: Tue Jun 23, 2015 9:59 pm
by FourthWorld
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?
In the Dictionary, for creating new objects see the "create" command, or for copying existing objects into a group see the "copy" command.

Re: Adding Objects To Groups

Posted: Tue Jun 23, 2015 10:08 pm
by Not a lot of thought
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?

Re: Adding Objects To Groups

Posted: Tue Jun 23, 2015 10:34 pm
by FourthWorld
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?
To create use "create".
For copy use "copy".
To change the layer of a control set its "layer" property, with the "relayerGroupedControls" global property set to true while you do it.

Re: Adding Objects To Groups

Posted: Tue Jun 23, 2015 10:37 pm
by dunbarx
Hi again.

Code: Select all

Wouldn't that then require me to delete the original control?
I think so. You can move a control out of a group by changing its layer. But you cannot insert a control into a group by the same means, interspersing its layer.

You can create a new control into a group, or you can copy a control into a group, but you cannot insinuate a control into a group.

Or am I wrong? Anyone?

Craig

Re: Adding Objects To Groups

Posted: Tue Jun 23, 2015 10:50 pm
by jmburnod
Hi Craig,
but you cannot insinuate a control into a group
Yes we can.
We have to know the layer of the first and last control of the target group and we can set the layer of a control
between this two layers.
Don't forget

Code: Select all

set the relayerGroupedControls to true
Best regards
Jean-Marc

Re: Adding Objects To Groups

Posted: Tue Jun 23, 2015 11:14 pm
by bn
Hi all,

if you want to move a control within a group to the top you can do this:

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
if you want to move a control to the lowest layer within a group do this

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
Just be careful, if the layer number is wrong you can "layer" the control out of the group.

Kind regards
Bernd

Re: Adding Objects To Groups

Posted: Wed Jun 24, 2015 4:22 am
by dunbarx
Ah, the reLayerGroupControls.

I forgot about that. From the dictionary:
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.
Right.

Craig