Page 1 of 1

Question about closeStack

Posted: Fri Oct 17, 2008 3:48 pm
by Paul D
I have a mainstack called A.

I have 3 substacks of A called B, C & D.

When I close B, C or D the closeStack message in A gets called everytime.

Why does it do this?

Posted: Fri Oct 17, 2008 3:54 pm
by Mark
Hi Paul,

Normally, you put a closeStack handler at the card level in your mainstack. If this is impossible, you might want to create a new mainstack and make all substacks including your current mainstack a substack of the new mainstack.

If that is impossible, too, you can check for the target.

Code: Select all

on closeStack
  if the short name of the owner of the target is the short name of me then
    -- do something when the mainstack closes
  else
    -- do something if a substack closes
  end if
end closeStack
Best,

Mark

Posted: Fri Oct 17, 2008 4:09 pm
by Paul D
is it normal for substacks to call a mainstacks closestack message?

Posted: Fri Oct 17, 2008 4:23 pm
by Mark
Hi Paul,

All messages follow the message hierarchy. So, the answer is yes.

Best,

Mark

Posted: Fri Oct 17, 2008 4:27 pm
by Paul D
well i ask because in the documentation the summary states...


closeStack
Type: message

Summary:
Sent to the current card when the stack closes.


but no where does it mention that if no closestack message in the currentcard, the mainstack message is called.

not a big deal but just pointing it out.

Posted: Fri Oct 17, 2008 4:37 pm
by Mark
Hi Paul,

It doesn't need to be mentioned because that's simply how Revolution and other xTalk platforms work.

Best regards,

Mark

Posted: Sat Oct 18, 2008 12:25 pm
by BvG
the message path / message hierarchy works like this:

frontscripts (if there are some)
object
group
card
background group (special case for hc compatibility)
substack (if we are in one)
mainstack
library stacks (if there are some)
backscripts (if there are some)
engine

so if you click a button, and it has no "mouseUp" handler, then all the mentioned steps will get the mouseUp, and at the end it vanishes into the void.

Now for "closeStack". you close stack B, so the card of stack B gets a closestack message. let's look at the relevant parts of the message hierarchy:

card (of stack B)
substack (stack B)
mainstack (stack A)

Obviously, stack A will recieve the closestack message, and if there is a closestack handler in it's script it will be executed.

Note also that custom commands and functions do not vanish, but throw an error if they do not exist (probably to make finding errors easier).

Posted: Mon Oct 20, 2008 3:24 pm
by Paul D
very good, thanks again for the help.