Grouping script
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Grouping script
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!
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!
-
- VIP Livecode Opensource Backer
- Posts: 9580
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Grouping script
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
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:
You might put a conditional in front of the "put" line to filter the objects you want:
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
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
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
Code: Select all
if the name of control y contains "XYZ" then put the name ...
Craig Newman
Re: Grouping script
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!
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!
-
- VIP Livecode Opensource Backer
- Posts: 9580
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Grouping script
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:
I am building essentially the same reference. Step through the handlers and see what is in "temp" in each case.
Craig
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
Craig
Re: Grouping script
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!!
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!!
-
- VIP Livecode Opensource Backer
- Posts: 9580
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Grouping script
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
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
Re: Grouping script
Hello dunbarx,
thanks for your help! & i already managed to solve the problem
thanks for your help! & i already managed to solve the problem
Re: Grouping script
I used a similar method in a repeat command (also grouping multiple groups into a group) as above.
Without repeating the whole code, it does result in
...where tObjectList is: group "Group 1" and group "Group 2"
BUT - I get this execution error: "group: object cannot be grouped."
I should note that both Group 1 and Group 2 are already within a Group, so that may be where the error is coming from (i.e., the desired result would be both Group 1 and Group 2 being in a new subgroup to a larger group).
What does this mean?
Without repeating the whole code, it does result in
Code: Select all
do "group" && tObjectList
BUT - I get this execution error: "group: object cannot be grouped."
I should note that both Group 1 and Group 2 are already within a Group, so that may be where the error is coming from (i.e., the desired result would be both Group 1 and Group 2 being in a new subgroup to a larger group).
What does this mean?
Re: Grouping script
Hi friends,
no need to DO anything!
Best
Klaus
no need to DO anything!
Code: Select all
...
repeat with y = 1 to the number of grps
set the selected of grp y to TRUE
end repeat
group
select empty
...
Best
Klaus
Re: Grouping script
Hi JereMiami,
You cannot group an object (group or wahtever) that is already part of another group!
So you can check if that is the case, if the group is NOT part of another group, its OWNER is the current card.
Best
Klaus
You cannot group an object (group or wahtever) that is already part of another group!
So you can check if that is the case, if the group is NOT part of another group, its OWNER is the current card.
Code: Select all
...
repeat with y = 1 to the number of grps
if word 1 of the owner of grp y = "card" then
## e.g. card id 1111 = NOT a subgroup
set the selected of grp y to TRUE
end if
end repeat
group
select empty
...
Klaus
Re: Grouping script
Hello there,
When I want to do something like that I always use the childControlIDs property. Since I discovered it it has helped me a lot jjj
See a possible solution to your problem using the childControlIDs property.
When I want to do something like that I always use the childControlIDs property. Since I discovered it it has helped me a lot jjj
See a possible solution to your problem using the childControlIDs property.
Code: Select all
local tChilds, tLongId
select empty
# set the layer of group"MyGrp" to 1
if there is a group 1 then ungroup group 1
put the childControlIDs of this card into tChilds
if the number of lines of tChilds > 1 then
repeat for each line tId in tChilds
put the long id of control id tId into tLongId
if word 1 of tLongId is no "group" then next repeat --> Groups only, remove to group all controls
set the selected of tLongId to true
end repeat
group
select empty
end if
Re: Grouping script
Thanks! It was part of another group and simply copying to "this card" (and not the group) before copying it into the group resolved the issue. Thanks everyone!