Group objects already grouped and set name of group

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
matgarage
Posts: 73
Joined: Sat Apr 20, 2013 11:39 am

Group objects already grouped and set name of group

Post by matgarage » Tue Sep 16, 2014 8:01 pm

Hello,

I'm trying to name a group of other groups by script

I set leGroupe as a list of groups to group.
And this script to do that.

Code: Select all

repeat for each line ligne in leGroupe
        set the selected of ligne to true
   end repeat
   group
    set the name of  last group to "GroupeName"
But in this case last group return the last group of graphic (child) of the last group in the list leGroupe (parent), but not the parent group.

I can't find how to rename this group of selected objects.

Someone can help me ?

matgarage

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Group objects already grouped and set name of group

Post by bn » Tue Sep 16, 2014 8:50 pm

Hi Matgarage,

last group will often not work as you found out. The reason is that last is determined by layer. But the layer of a group of groups is the lowest layer of those groups.

I would use a work around that makes use of the fact that when you know the groups your are grouping those groups will be "owned" by your super group "groupeName"

Code: Select all

   repeat for each line ligne in leGroupe
      set the selected of ligne to true
   end repeat
   group
   set the name of the owner of (line 1 of leGroupe)  to "GroupeName"
you simply ask for the owner of one of the groups that are now grouped and rename the owner.

Kind regards

Bernd

matgarage
Posts: 73
Joined: Sat Apr 20, 2013 11:39 am

Re: Group objects already grouped and set name of group

Post by matgarage » Tue Sep 16, 2014 9:01 pm

Yes ! It's working.
Bernrd, this simple concept will boost my future coding strategies .
Thank you .

Matthieu

Post Reply