Demo Show Stopper - Save File Dialog

David Burgun dburgun at dsl.pipex.com
Mon Apr 26 10:02:40 EDT 2004


>>>And saving the stack shortly before closing it (but not in the 
>>>closestack or closestackrequest) does not work?
>>
>>Not sure what you mean by "but not in the closestack or 
>>closestackrequest". The stack scripts are as follows:
>>
>>on preOpenStack
>>set the destroyStack of this stack to true
>
>this is persistent property, so you can set it in IDE and you do not 
>need to reset it each time the stack opens.

Right, but it doesn't cause any harm right? In some cases (in another 
Script) I was actually resetting it depending on what the user did. 
Not sure if I need that now.

>
>>set the CustomSaveStackFlag of this stack to true
>
>I wonder whether the change of this flag during the execution does 
>not prompt your problem dialog. May be the other stack does not 
>change it for some reason. There is something different about their 
>execution for sure.

The other stacks do set this value in the same way, so I can't see 
why it would affect this one stack. I will try taking this out and 
see what happens, although I am sure I've tried this before.

>You could try using global instead of custom property. Global does 
>not affect the dirty flag.

Do you mean just temparilly? I asked about this before and someone 
else told me it was better to use a Property. I will try taking it 
out altogether.

But apart from anything else "destroyStack" is true, so shouldn't 
this stop the dialogs from being displayed?
>>
>>pass preOpenStack
>>end preOpenStack
>>
>>on closeStack
>>if theCustomSaveStackFlag of this stack is true
>>     save this stack
>>end if
>>
>>pass closeStack
>>end closeStack
>>
>>This is basically the same as the other stacks that do not display 
>>the dialog. I am not sure where to put the "save this stack" if not 
>>in the closeStack handler. I want the Stack to be saved just before 
>>it is closed.
>
>As I told you earlier, the check for dirty is done before closestack 
>messages are sent. So to truly fix it (for running in IDE), you need 
>to figure out what causes the change in your stack and do a 
>pre-emptive save somewhere.

But this works just fine in all the other stacks! I can't seem to 
find the right message to issue a save before the check is performed. 
Is there a place?

>>Here's what I do to show the problem:
>>
>>Open the Stack in the IDE, Save It and close it.
>>Select "Browser" Mode in the IDE.
>>Run the Dummy Stack that has the Menubar and Menu handlers.
>>Select a Stack that does not exhibit this problem (via the Menubar).
>>Press buttons etc in the Stack and press Close Box (Button at 
>>top/left of window on MacOS) - Stack closes no problem.
>>Select the Stack that does exhibit this problem (via the Menubar).
>>Press Close Box (Button at top/left of window on MacOS) - I get the 
>>"Do you want to save this stack?" dialog.
>>
>>Any Ideas?
>
>As a workabout, try using not the close box but add a button that 
>does save (it can check the flag or not) and then issues close this 
>stack.

In all the other stacks I don't have this problem! They basically do 
the following:

OK:
on mouseUp
set the CustomSaveStackFileFlag of this stack to true
close this stack
end mouseUp

Cancel:
on mouseUp
set the CustomSaveStackFileFlag  of this stack to false
close this stack
end mouseUp

The the closeStack handler is as above. This works just fine is all 
other stacks! This dialog doesn't have such a button though. Sure I 
can add one for testing, but I don't want/need a button in the real 
app.

The problem is that I just want one place where the Stack is Saved, I 
opted for the closeStack handler, but if this isn't the correct place 
to do this, then which message to I handle. The user may press the 
Close Stack Button which doesn't have any code to save the stack, I 
therefore thought to handle in the one place where all close stacks 
end up, namely the "closeStack" handler.














More information about the use-livecode mailing list