Grouping two objects and grabbing the group

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
fergusondavid6
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2
Joined: Mon Apr 01, 2013 3:51 pm

Grouping two objects and grabbing the group

Post 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?
FredBeck
Posts: 77
Joined: Fri Nov 01, 2013 3:07 pm
Contact:

Re: Grouping two objects and grabbing the group

Post 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.
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10504
Joined: Wed May 06, 2009 2:28 pm

Re: Grouping two objects and grabbing the group

Post 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
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Grouping two objects and grabbing the group

Post 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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10504
Joined: Wed May 06, 2009 2:28 pm

Re: Grouping two objects and grabbing the group

Post 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
Post Reply