Question about closeStack

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Question about closeStack

Post by Paul D » Fri Oct 17, 2008 3:48 pm

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?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Oct 17, 2008 3:54 pm

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
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

Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Post by Paul D » Fri Oct 17, 2008 4:09 pm

is it normal for substacks to call a mainstacks closestack message?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Oct 17, 2008 4:23 pm

Hi Paul,

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

Best,

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

Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Post by Paul D » Fri Oct 17, 2008 4:27 pm

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.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Oct 17, 2008 4:37 pm

Hi Paul,

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

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Sat Oct 18, 2008 12:25 pm

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).
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Post by Paul D » Mon Oct 20, 2008 3:24 pm

very good, thanks again for the help.

Post Reply