Page 1 of 1
Set group rect to its child contents
Posted: Sat May 20, 2023 10:49 pm
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
Re: Set group rect to its child contents
Posted: Sat May 20, 2023 10:54 pm
by 5imon
HA! Managed to find the answer in a 2017 mailing list.
set the clipsToRect of group "Canvas" to false
Re: Set group rect to its child contents
Posted: Sun May 21, 2023 4:54 pm
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.
Re: Set group rect to its child contents
Posted: Sun May 21, 2023 7:30 pm
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.
Re: Set group rect to its child contents
Posted: Sun May 21, 2023 8:39 pm
by FourthWorld
For creating a canvas you may also find the boundingRect group property useful.
Re: Set group rect to its child contents
Posted: Sun May 21, 2023 11:22 pm
by 5imon
Thanks Richard, the boundingRect actually works very well.

Re: Set group rect to its child contents
Posted: Mon May 22, 2023 1:26 am
by FourthWorld
5imon wrote: ↑Sun May 21, 2023 11:22 pm
Thanks Richard, the boundingRect actually works very well.
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.