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: Klaus, FourthWorld, heatherlaine, kevinmiller

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

Expanding borders of Groups

Post by richmond62 » Sat May 14, 2016 9:13 pm

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: 3479
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Expanding borders of Groups

Post by richmond62 » Sat May 14, 2016 9:29 pm

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: 173
Joined: Sat Dec 09, 2006 1:27 am
Location: Los Angeles

Re: Expanding borders of Groups

Post by jiml » Sun May 15, 2016 3:31 pm

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: 173
Joined: Sat Dec 09, 2006 1:27 am
Location: Los Angeles

Re: Expanding borders of Groups

Post by jiml » Sun May 15, 2016 3:40 pm

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: 5084
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Expanding borders of Groups

Post by jacque » Sun May 15, 2016 3:42 pm

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: 3479
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Expanding borders of Groups

Post by richmond62 » Sun May 15, 2016 5:52 pm

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: 5084
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Expanding borders of Groups

Post by jacque » Sun May 15, 2016 6:45 pm

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: 3479
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Expanding borders of Groups

Post by richmond62 » Sun May 15, 2016 6:57 pm

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: 5084
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Expanding borders of Groups

Post by jacque » Sun May 15, 2016 7:11 pm

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: 3479
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Expanding borders of Groups

Post by richmond62 » Sun May 15, 2016 7:18 pm

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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”