preOpenStack, openStack in Card 1?? Rules conformation.
ambassador at fourthworld.com
Thu Mar 30 11:20:37 EST 2006
David Burgun wrote:
> I remember a while back I saw something about the preOpenStack and
> openStack handlers in Card 1 of the mainStack. Since then I have
> always placed these handlers in Card 1 and "passed" them (via pass
> command) to the Stack. However I can't seem to find that email
> anymore, could someone elaborate on how this works?
Most messages are generally sent to the highest object in the message
path for which the message is relevant. For example, when you select a
control that control gets the selectedObjectChanged message.
For messages that have no specific control, like openStack,
preOpenStack, etc., those are sent to the card. They can be trapped
there, or handled in the stack, depending on the scope of what you want
to accomplish, or even handled in the mainStack or a library or a
For behaviors specific to my mainstack, I tend to put those in the
mainStack's card script (or if there are multiple cards in my mainStack
-- rare for me since I tend to use the mainStack as a repository of
handlers -- I use a group in the mainStack). I do this because the
mainStack's stack script is available to all substacks, and the
alternative requires a decision point ("if the short name of the target
is the short name of me"); to minimize complexity I try to keep decision
points to a minimum (more on code complexity and its implications for
maintenance coming in an article at revJournal soon).
Initialization of course needs to be done only once, and the mainStack's
first card will be the first recipient of the startup, openStack, and
preOpenStack messages. The startup message is only sent at runtime (the
IDE gets it in development), so to get initialization in both
development and runtime I use preOpenStack instead.
For readability I tend to structure my initialization like this:
...where each of those "Init*" handlers are also included the card script.
As a matter of tidiness I usually pass all system messages, in case some
other object is added down the road which needs them. With
initialization, however, I prefer that everything be handled in one
place so I don't pass that preOpenStack message.
I'm not sure if this is exactly what you were looking for; hope it helps.
Managing Editor, revJournal
Rev tips, tutorials and more: http://www.revJournal.com
More information about the Use-livecode