Page 1 of 1
Grouping two objects and grabbing the group
Posted: Tue Jan 19, 2016 8:53 pm
by fergusondavid6
Hi,
I'm trying to group two objects together using the group command, and then grab the newly-created group, all in one single mouseDown message.
I've tried the following code:
Code: Select all
on mouseDown
group me and button 2
grab the last group
end mouseDown
And while this groups the two objects together, it does not grab them.
Can someone please tell me how to do this?
Re: Grouping two objects and grabbing the group
Posted: Wed Jan 20, 2016 10:38 am
by FredBeck
Hi David,
All in one mouseDown message? Some code golf competition I guess...
Anyway, doing :
Code: Select all
on mouseDown
grab graphic 1
end mouseDown
Just as the dictionary says only works when placed in the card script
It seems implicit that you can only grab the target of the mouse event.
Fred.
Re: Grouping two objects and grabbing the group
Posted: Wed Jan 20, 2016 3:42 pm
by dunbarx
Hi.
Also be aware that the "last" keyword is not stable with groups. Check the user notes in the dictionary for a workaround. There is no such issue with any other control
Craig Newman
Re: Grouping two objects and grabbing the group
Posted: Fri Jan 22, 2016 1:56 am
by jacque
dunbarx wrote:Also be aware that the "last" keyword is not stable with groups. Check the user notes in the dictionary for a workaround. There is no such issue with any other control
I'm not sure that it's unstable, it just follows some pre-determined rules. The "last" of any object is the one with the highest layer number. If you create new groups directly on the card, the last one will be the most recent. If you create a new group inside another group, then its layer won't be the highest and it won't be the "last" one.
Re: Grouping two objects and grabbing the group
Posted: Fri Jan 22, 2016 3:01 am
by dunbarx
Jacque
Hi.
I know what you are getting at, but I believe my tests of years ago made sure that all controls in the "last" group were also the newest controls. I will test again next week when I am back in the office.
Unless someone has nothing better to do.
Craig