Question about closeStack
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Question about closeStack
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?
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?
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.
Best,
Mark
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
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Hi Paul,
It doesn't need to be mentioned because that's simply how Revolution and other xTalk platforms work.
Best regards,
Mark
It doesn't need to be mentioned because that's simply how Revolution and other xTalk platforms work.
Best regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
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).
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).
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode