Expanding borders of Groups

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10416
Joined: Fri Feb 19, 2010 10:17 am

Expanding borders of Groups

Post by richmond62 »

If I make a group of 2 objects, where the largest is 120 x 120 pixels the group measures 128 x 128 pixels:
group1.png
This is not always what one wants.

I often want my group to be the same size as the biggest object within it.
HOWEVER, if I resize my group to 120 x 120 pixels the component objects end up being displaced:
group2.png
The way to avoid this is fiddly, but effective: one has to centre each component object using the
Properties Palette:
group3.png
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10416
Joined: Fri Feb 19, 2010 10:17 am

Re: Expanding borders of Groups

Post by richmond62 »

To speed things up, having grouped ones objects, one can then unGroup them
again and position them all together, and then reGroup them.
group4.png
jiml
Posts: 341
Joined: Sat Dec 09, 2006 1:27 am

Re: Expanding borders of Groups

Post by jiml »

Richmond,

Just set the margins of the group to 0 (zero).

It will contract to the size of the largest object within.

Jim Lambert
jiml
Posts: 341
Joined: Sat Dec 09, 2006 1:27 am

Re: Expanding borders of Groups

Post by jiml »

Rather it will contract to the extents of the objects within the group.

When you group objects LC adds a 4 pixel margin.
So if you have a 120x120 object and then group it, the group will be 128x128 - as your example shows.
Simply set the group's margin to 0, and you will end up with a group that is 120x120.

Jim Lambert
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Expanding borders of Groups

Post by jacque »

Besides margins, turn off lockLoc. It's preventing the group from automatically snapping to the size of the components.

You can turn it on again after it resizes if you want.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10416
Joined: Fri Feb 19, 2010 10:17 am

Re: Expanding borders of Groups

Post by richmond62 »

Thanks jacque and jimi both!

However, the dictionary says this:
By default, the lockLocation property of a newly created control is set to false.
So I wonder why one needs to turn it OFF for a group.
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Expanding borders of Groups

Post by jacque »

It's off by default unless something has changed the templateGroup, but in your images it's been turned on.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10416
Joined: Fri Feb 19, 2010 10:17 am

Re: Expanding borders of Groups

Post by richmond62 »

Well, I locked my images, but I DIDN"T lock my Group when
I grouped the images.

Maybe, had I not locked the images initially . . . .
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Expanding borders of Groups

Post by jacque »

I just tested in LC 8 and grouping does not set the lockLoc of the group to true. You may have had selectGroupedControls turned off when you locked what you thought was an image, and accidentally locked the group instead.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10416
Joined: Fri Feb 19, 2010 10:17 am

Re: Expanding borders of Groups

Post by richmond62 »

I just tested in LC 8
I did that in 7.1.4.
Post Reply