I must be missing something

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: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

I must be missing something

Post by magice » Fri Mar 27, 2009 3:15 pm

I have created a mainstack and a substack. They work together as intended. The problem I am having though, is that when I initially open the the project, the substack doesn't open. I have to go to the application browser and open it from there. Am I missing a simple property setting, or do I somehow need to script the opening of that substack?

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1682
Joined: Sat Feb 28, 2009 11:49 pm

Post by sturgis » Fri Mar 27, 2009 3:25 pm

Not sure this is the best way, but try

Code: Select all

on preOpenStack
show stack "stackname"
end preOpenStack
In the main stack script.

I'm still new, but I think that since its showing in the app browser it is actually open, just not showing.

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Post by magice » Fri Mar 27, 2009 3:42 pm

unfortunately that didn't seem to help. I still have to go to the application menu and open the substack before it wil interact with the main stack.

Klaus
Posts: 11825
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Post by Klaus » Fri Mar 27, 2009 3:57 pm

Hi magice,

try:

Code: Select all

on preOpenStack 
  GO stack "stackname" 
end preOpenStack
"show stack XYZ" will only set the "visible" property but not open the stack!


Best from germany

Klaus

massung
Posts: 93
Joined: Thu Mar 19, 2009 5:34 pm

Post by massung » Fri Mar 27, 2009 4:08 pm

I'm new to Revolution, but my experience so far shows that using openStack or preOpenStack is probably a bad idea. That handler will be called again when you actually open the substack (or any other substack), too. This is probably not what you want to have happen.

If you put it in openCard of the main stack, then it will only happen when you initially open the main stack.

If I'm seeing the above behavior due to a misunderstanding I have on how stack scripts are executed, then perhaps someone here can correct me and explain why that is, though. ;)

Jeff M.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1682
Joined: Sat Feb 28, 2009 11:49 pm

Post by sturgis » Fri Mar 27, 2009 4:26 pm

ah k. A DOH moment for me, thanks for the catch.

Also is stated just above, it probably is a good idea to put it in cardOpen rather than preOpenStack

I've run into some wierdness with drawers due to this.
Klaus wrote:Hi magice,

try:

Code: Select all

on preOpenStack 
  GO stack "stackname" 
end preOpenStack
"show stack XYZ" will only set the "visible" property but not open the stack!


Best from germany

Klaus

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Post by magice » Fri Mar 27, 2009 5:12 pm

That did it, thank you very much.

Obleo
Posts: 174
Joined: Mon Apr 10, 2006 10:35 pm
Location: Chicago
Contact:

Post by Obleo » Sat Mar 28, 2009 7:58 am

massung wrote:I'm new to Revolution, but my experience so far shows that using openStack or preOpenStack is probably a bad idea. That handler will be called again when you actually open the substack (or any other substack), too.
Jeff M.
Really ? I never heard of that or had any such problem in the years I used revolution doing any such thing. It is called once when the main stack is opened. each substack has it's own stack script. If there no such handler in the substack it will not tigger that meassage again.

I'd be interested to see a stack that did otherwise.

SparkOut
Posts: 2226
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Sat Mar 28, 2009 10:48 am

The preOpenStack and openStack messages pass through the hierarchy as usual when a substack is opened as well.

If you make a plain mainstack "myMainStack" and substack "mySubStack" with no controls on them and put the following in the stack script of the mainstack

Code: Select all

on preOpenStack
   answer "preOpenStack triggered in mainstack"
end preOpenStack

on openStack
   answer "openStack triggered in mainstack"
   go stack "mySubStack"
end openStack
then you will find that the mainstack preOpenStack and openStack messages are triggered twice each - once when the mainstack opens, and again when the substack opens - because the preOpenStack and openStack messages are not handled in the substack, then the messages pass up the hierarchy to the mainstack in the usual manner. Therefore you need to consider the message path hierarchy when making stack level handlers. Either you need to trap them in substacks where the mainstack handlers should not trigger, or, you can move the preOpenStack and openStack handlers to card 1 of the mainstack, which will mean that a substack's message will not be trapped by the mainstack stack script - it doesn't pass through all the cards, whereas by default a stack will open card 1 of that stack as it opens.
(Not a very coherent paragraph, but I hope you get what I mean.)

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”