Set group rect to its child contents

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
5imon
Posts: 19
Joined: Fri Nov 22, 2019 8:09 pm

Set group rect to its child contents

Post by 5imon »

I'll start by saying the solution to my problem is solved by toggling the "Clip child controls to rect" checkbox in the Property Inspector. Unfortunately I don't recall if we can actually see the code behind the the various IDE elements in LiveCode.

So here's the problem:

I have a group with random elements within it. At some point the rect of the group is getting modified which causes the rect to clip its content somewhat.

I'm trying to find a way to *reset* the group's bounds/rect to that of its contents so that the groups border perfectly matches the rect of all its contents. "Clip child controls to rect" does this perfectly, but I need it to work in script.

Simon
5imon
Posts: 19
Joined: Fri Nov 22, 2019 8:09 pm

Re: Set group rect to its child contents

Post by 5imon »

HA! Managed to find the answer in a 2017 mailing list.

set the clipsToRect of group "Canvas" to false
jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Set group rect to its child contents

Post by jacque »

You said you want the group to enclose it's contents, but clipsToRect will cut off any controls that exceed the boundaries. Is that the goal? If not, you might want to look at formattedHeight and formattedWidth.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
5imon
Posts: 19
Joined: Fri Nov 22, 2019 8:09 pm

Re: Set group rect to its child contents

Post by 5imon »

Hi Jacque,

yes, for the moment I need it to act as a clip as the group itself is acting like a canvas of sorts. Anything outside those bounds is "off canvas".

But thanks for the info about the formattedHeight and formattedWidth, I'm sure I'll need those too as I progress through this project.
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Set group rect to its child contents

Post by FourthWorld »

For creating a canvas you may also find the boundingRect group property useful.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
5imon
Posts: 19
Joined: Fri Nov 22, 2019 8:09 pm

Re: Set group rect to its child contents

Post by 5imon »

Thanks Richard, the boundingRect actually works very well. :o
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Set group rect to its child contents

Post by FourthWorld »

5imon wrote: Sun May 21, 2023 11:22 pm Thanks Richard, the boundingRect actually works very well. :o
Glad you like it. I co-invented it brainstorming with Scott Raney back in the old MetaCard days, as a way to provide an LC-savvy way to get something like SuperCard's backsize property.

I haven't used boundingRect often, but it's very handy when creating certain document UIs that need a canvas of a fixed size. I'll probably be using it again shortly, now that I'm making some print-oriented tools for board game design.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Post Reply