Grouping script

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
jwtea
Posts: 65
Joined: Fri Mar 23, 2018 2:01 am

Grouping script

Post by jwtea » Fri Apr 27, 2018 4:14 am

Hello,

anybody know how to create a group that can group all those small group??

I got alot of group and i want to group all as 1 so that i can make it scrollable as
the content is not enough to fit in my size.

Any help is appreciated!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5646
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Grouping script

Post by dunbarx » Fri Apr 27, 2018 5:13 am

Hi.

Do you mean a handler that can create a large group from a bunch of controls or groups? This is easy to do by hand. You simply select objects with the shiftKey, and hit the group icon in the menuBar.

Or, if you know the names of the groups of interest, you can write something like

Code: Select all

on mouseUp
    select group "aa" and grp "bb"
   group 
end mouseUp
The word "and" allows this to go forward.

But if you do not know the names of the groups, but want to group any number of them, you need (I think) to do something a little more sophisticated:

Code: Select all

on mouseUp
   repeat with y = 1 to the number of grps -- and/or controls
      put the name of grp y && "and "  after temp
   end repeat
   delete the last word of temp
   do "select" &&  temp
   do  "group" && temp
end  mouseUp
You might put a conditional in front of the "put" line to filter the objects you want:

Code: Select all

if the name of control y contains "XYZ" then put the name ... 
But now looking at the dictionary, I see that there is yet another way, to use an "objectList" as the list of groups or controls to, er, group. This objectList seems to be an array, and I am not sure how it is constructed. Someone else will chime in, though.

Craig Newman

jwtea
Posts: 65
Joined: Fri Mar 23, 2018 2:01 am

Re: Grouping script

Post by jwtea » Fri Apr 27, 2018 5:20 am

Hello , thanks for your fast replies!!

I had some issue because.... i got 4 groups and this 4 groups got the same name... or you got any idea to
group the whole card???

Thanks!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5646
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Grouping script

Post by dunbarx » Fri Apr 27, 2018 2:42 pm

Hi.

Well, first off, it is usually bad practice to have controls (or groups) have the same name.

But you can use other properties, such as the number, to collect these objects:

Code: Select all

on mouseUp
   repeat with y = 1 to the number of grps -- and/or controls
      put "group" && y && "and "  after temp
   end repeat
   delete the last word of temp
   do "select" &&  temp
   do  "group" && temp
end  mouseUp
I am building essentially the same reference. Step through the handlers and see what is in "temp" in each case.

Craig

jwtea
Posts: 65
Joined: Fri Mar 23, 2018 2:01 am

Re: Grouping script

Post by jwtea » Mon Apr 30, 2018 2:23 am

Hello ,

Thanks above the script worked perfectly!!

But can i ask you why everytime i move the location of my box, when it hit the maximum height it will auto go to the middle??

Example : my first box will move to 150,200 location then second box will move to 150,400 then my third box will move to 150,600. But my fourth box and fifth box will auto go to the 150,165 .... (i'm using repeat coding for the moving of box)

Any idea i can go let them go 150,800 then 150,1000 and continue..... then after that i can use my script to group down and allow scrolling??

Thanks!!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5646
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Grouping script

Post by dunbarx » Mon Apr 30, 2018 6:52 pm

Hi.

I am not sure I understand.

By "box" do you mean "field"? And when you run the handler, you are seeing the controls or groups moving all by themselves? You may have to post an example stack.

In any case, you can always add a short repeat loop that sets the loc of each group in any way you want to. Do you need help with that?

Craig

jwtea
Posts: 65
Joined: Fri Mar 23, 2018 2:01 am

Re: Grouping script

Post by jwtea » Wed May 02, 2018 2:08 am

Hello dunbarx,

thanks for your help! & i already managed to solve the problem 8)

Post Reply

Return to “Talking LiveCode”