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
Check all objects on a stack/card?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- 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?
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.:
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn