Getting palette buttons to work on another stack
Sarah Reichelt
sarahr at genesearch.com.au
Mon Mar 1 21:33:48 EST 2004
Jonathan is having email problems and asked me to forward this to the
list - Sarah.
-------------------
What's the best way to get a palette button to work on another stack? In
HyperCard, you could refer to an object (e.g. "field 1") in a
palette-button's handler and it would be obvious that this would refer
to
that object on the current card (of the current stack). However, in
Revolution, palettes are stacks, so it's not so easy.
With a bit of digging around the Transcript Dictionary ("defaultStack",
"mainStack", "mainStacks()", "stacks()", "stackFiles", "topStack()"
[="currentWindow()"], "openStacks()" [="windows()"],
"revLoadedStacks(application)" !) I came up with the following handler,
which works. It's to toggle the lock property of all fields on a card:
on mouseUp
put the short name of the topStack into activeStack
lock screen
lock messages
push cd
go activeStack
repeat with i=1 to the number of flds
set cursor to busy
set lockText of fld i to not (lockText of fld i)
end repeat
pop cd
end mouseUp
Interestingly, it also seems to work even if the "palette" stack is made
"topLevel". (I expected it would have regarded itself as the topStack
but
there you go.)
Is this the way you're meant to do it? It seems a little clumsy -
especially with the lock screen; push cd; go...; pop cd stuff.
Thanks,
Jonathan Cooper
Manager of Information / Website
Art Gallery of New South Wales
Sydney, Australia
http://www.artgallery.nsw.gov.au
More information about the use-livecode
mailing list