Best Way to do Multiple Instances of a Stack
Sarah
sarahr at genesearch.com.au
Tue Sep 16 13:49:00 EDT 2003
Hi Brian,
There are a few wrinkles to this, mainly to do with making sure the
cloned stack doesn't appear briefly before you position it and re-draw
it. This example assumes a sub-stack called "Clone" that will be cloned
to become your new display stack (sorry it's a bit long-winded, but it
took me a lot of time, and a lot of help from others on this list, to
work all this stuff out):
-- script to start off the process:
cloneStack "Display Stack 1"
-- The cloneStack handler is in the stack script of my main stack:
on cloneStack newName
if (newName is among the lines of the openStacks) then
go to stack newName in a new window
else
-- work out positioning for the new stack & set a custom property
in the original
-- I use the topLeft position
set the cPresetTL of stack "Clone" to "100,100"
clone stack "Clone"
set the name of stack "Copy of Clone" to newName
end if
end cloneStack
The original "Clone" stack is set to destroyStack & destroyWindow as
these copies are for temporary displays only. This means that they
disappear whenever their windows are closed and don't get saved with
the rest.
The original (& therefore the clone) has a preOpenStack handler as
follows:
on preOpenStack
open invisible me
set the topleft of me to the cPresetTL of me
-- now update the display in the new stack
-- my drawGraphics handler does all this
send "drawGraphics" to me in 5 ticks
end preOpenStack
I wouldn't have thought that an open invisible command would have
worked within a preOpenStack handler as it is already opening, but it
really does. Strangely, you don't even need to make the stack visible -
it just appears in the correct place.
One further wrinkle (& the reason why my drawGraphics handler is not
called immediately) - cloning a stack overrides the lock screen
command, so at first, my graphics were drawing visibly and slowly. I
tried putting another lock screen command at the start of my
drawGraphics handler but it still didn't work until I used a send to
call drawGraphics after a delay.
Cheers,
Sarah
sarahr at genesearch.com.au
http://www.troz.net/Rev/
On Wednesday, September 17, 2003, at 07:36 am, Brian K. Maher wrote:
> Hi Folks,
>
> I have the need for my end users to be able to see multiple instances
> of a given window (substack) where each window would have a different
> title/label and would display different data from a database. What is
> the best way to accomplish this? Specifically ... if you use the
> clone command what is the best way to "initialize" the clone?
>
> Thanks, Brian Maher
>
More information about the use-livecode
mailing list