Check all objects on a stack/card?

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
DevBoyLars
Posts: 216
Joined: Wed Feb 27, 2013 9:04 pm

Check all objects on a stack/card?

Post by DevBoyLars » Sat Apr 25, 2015 1:17 pm

Hi there,
I want to write a script, which resizes all of my objects on a card/stack. So I want to know: Is there a way to request LiveCode what objects are on the current card/stack? If yes, I could write a universal-resize-code and don't have to edit it for every object again and again :)

Thank you :)

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

Re: Check all objects on a stack/card?

Post by FourthWorld » Sat Apr 25, 2015 5:34 pm

LiveCode's Geometry Manager is a generalized solution which aims to provide a point-and-click way to set up resizing relationships between objects. There's also a commercial toolkit available for a similar scope done through different means:
http://lessons.runrev.com/m/4068/l/2093 ... etry-guide

With all due respect, I think you may find the task of attempting a one-size-fits-all handler for resizing objects somewhat daunting. Unless you use one relatively simple layout over and over, you may find as I have that there are some objects that need to be resized according to the window edge, other according to the edges of other objects, and maintaining the order in which such things are evaluated to ensure good layout is quite a task.

For myself, I've found it much easier to hand-code resizeStack handlers for each card, and for groups I often use resizeControl handlers so I can copy-and-paste those groups easily and the resizing behavior goes along for the ride.

Sure, it's a bit of work, but more tedious than difficult, and you only write it once and move on to more interesting tasks. I've found the time spent well worth the upsides: by hand-coding my resizing I have complete control over every aspect of the layout, executed in the most efficient way possible.

Even with the time required for hand-coding, if you account for the time it takes to learn and use any point-and-click option, or write your own generalized solution, the net gain isn't very much. Moreover, the likelihood that you may eventually run into edge cases that the generalized solution doesn't account for is often greater than zero. I prefer the certainty of custom code, and it only takes a few minutes per layout so for me it's been time well spent.

All that said, to answer your original question you can obtain a list of control by iterating through the controls in a counter loop, e.g.:

Code: Select all

repeat with i = 1 to the number of controls
   put the long id of control i &cr after tObjList
end repeat
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”