Page 1 of 1
Quit sometimes works
Posted: Sun Jan 08, 2012 8:45 am
by John
I can't seem to figure out what I am missing. I have a main stack with several substacks. All of then use the same menu bar. When I build a stand alone, the Quit menu item is called if I have not opened one of the substacks. Opening and closing a substack seems to keep the menu handler script from firing for Quit only ( this is under OSX so the Quit menu item appears in the app under the applications menu rather than FIle). All of the other menus keep working however (even those under the File menu in menu builder). Why is the Quit menu item treated differently and what do I do so that it can be called? Closing the windows does quit the app which is also undesirable but livable.
Thanks,
John
Re: Quit sometimes works
Posted: Sun Jan 08, 2012 5:50 pm
by Mark
Hi John,
The Quit menu item works independently of scripts, but before your LiveCode standalone quits, the shutDownRequest handler will be executed. Example:
Code: Select all
on shutdownRequest
close stack "substack 1"
put empty into field 'Some Field" of stack "Mainstack"
pass shutdownRequest
end shutdownRequest
Kind regards,
Mark
Re: Quit sometimes works
Posted: Sun Jan 08, 2012 7:49 pm
by John
Mark,
Thanks for the reply. I did place a shutdownRequest handler in backscript to handle other things but did not close the substacks in it. I just added the "close stack" bits to close the substacks and my backscript now looks like:
on shutDownRequest
local theFile
put makePreferencesFile() into theFile
writePreferences theFile
close stack "substack 1"
close stack "substack 2"
close stack "substack 3"
close stack "substack 4"
close stack "substack 5"
pass shutDownRequest
end shutDownRequest
This did not work. Placing this in the main stack script also did not work. I added a close stack for the main stack as well to no avail. Any other suggestions? The preferences file is created only if another substack had not been opened previously indicating that a shutdown request is never generated. The application still does not quit until I close the main stacks window with the red jewel.
Thanks,
John
Re: Quit sometimes works
Posted: Sun Jan 08, 2012 8:47 pm
by John
Mark,
I should have read what you were saying a bit more carefully. In the scripts where I was writing the current state of the application (my script makePreferencesFile) I was referring to some fields and buttons on the main stack. Apparently the main stack is 'gone' for lack of a better term even though the script is executing from its (the main stacks) stack script. I removed the back script to verify this. So, if I use the long form and append a ' of stack "main stack" ' to all field and button references it works. Apparently a script error cancels the quit process. In any case it is solved.
Thanks,
John
Re: Quit sometimes works
Posted: Sun Jan 08, 2012 10:36 pm
by Mark
Cool. I'm glad it works now.