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 » Sat May 20, 2023 10:49 pm

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 » Sat May 20, 2023 10:54 pm

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

Re: Set group rect to its child contents

Post by jacque » Sun May 21, 2023 4:54 pm

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 » Sun May 21, 2023 7:30 pm

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: 9857
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Set group rect to its child contents

Post by FourthWorld » Sun May 21, 2023 8:39 pm

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 » Sun May 21, 2023 11:22 pm

Thanks Richard, the boundingRect actually works very well. :o

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9857
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Set group rect to its child contents

Post by FourthWorld » Mon May 22, 2023 1:26 am

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

Return to “Getting Started with LiveCode - Experienced Developers”