Not a bug in the way you mean, but it's a documentation bug, and you should post it at the
quality center.
The last group is always the topmost group (layer with the largest number). if you group a group, the new group is placed at the topmost place. but objects within the group are always at a higher layer then the group that contains them.
So in your example this is the layering (layer number in front), when your code is finished:
Code: Select all
1 group "group id <idnumber>"
2 -> group "G1"
3 - -> field "A"
4 - -> field "B"
5 -> group "G2"
6 - -> field "C"
7 - -> field "D"
As you see, the topmost group is "G2", and the group you actually want is bottommost, because the new group contains all other groups.
The problem is, there's no single way to set names of a newly created group, all methods have some backdraw:
- the layer (last, topmost etc.) will not work (as seen) if the new group contains groups
- setting the name of the templategroup will not work if any object in your new group was grouped then ungrouped and you didn't leave the card since then (because in that case the name is set to what the old group was named, see the "ungroup" entry of the docu).
- using the "newGroup" message is probably the easiest, but not really obvious, and quite a clunky workaround.
- there's probably other ways that I have forgotten/don't know
Probably RunRev should put the "newgroup" message as an example into the documentation, or fix the group command to put an object reference into the "it" variable, as every other creation of an object does.
Example code (needs to be at card or higher level in the message path):
Code: Select all
on newGroup
set the name of the target to the newGroupName of me
end newGroup
Example code to rename your group (in mouseUp or groupBug or whatever handler):
Code: Select all
on mouseUp
set the newGroupName of this card to "G3"
group group "G1" and group "G2"
end mouseUp