william humphrey wrote:
If you have a mainstack and lots of substacks and you put either
a preopenstack or an openstack in the mainstack you would think that it
would only be called when you first open your stack. Not true. It is called
every time you switch to any of the other substacks of your main stack.

Right. Substacks inherit the script of the mainstack automatically. The message hierarchy works normally, and if nothing in a substack catches the message, it will pass through to the mainstack. This is good if you have certain behaviors you want to happen every time a stack opens (like updating a window menu, maybe) but not so good if you only want something to happen when the mainstack opens.

There are many ways to deal with this, and two have already been suggested:

1. If you only want something to happen once when the mainstack opens, put the openstack or preOpenStack handler in the first card of the mainstack. Substacks don't inherit the scripts of mainstack cards, only the one in the stack script, so handlers in the cards won't be called by substacks. When a mainstack first opens, it always opens at the first card, so the handlers will trigger from there.

2. Use blocking handlers. Put empty "openStack" or "preOpenStack" handlers in the stack scripts of the substacks. When they open, the blocking handlers will catch the messages, which won't go through to the mainstack. This is only convenient if you have one or two substacks, otherwise it's too much trouble.

3. If you really do need to put the handlers in the mainstack script, check to see if the stack that is opening is one you want to deal with. This is a good approach if you want to trigger an openStack handler in some substacks but not all of them. So you can do this:

 if the short name of this stack is not in "substack1,substack2"
 then pass openStack -- or "exit" if you like

That lets you decide which stacks should handle the message.

If you want only the mainstack to handler it, you can do this:

  if the short name of this stack is not the short name of me
  then pass openStack

But in this case you may as well put the handler into the first card instead.
--
Jacqueline Landman Gay         |     jac...@hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to