Quit vs Close stack
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Quit vs Close stack
I'd like to be sure that if user close my app, I can save changed data to MySql db. I'd like to display the warning "Your changed data are not saved into the database", co he could cancel the close app procedure, and check why data is not saved (the reason could be broken internet connection).
There is no problem if user quits by:
- pressing close window icon - as I can use closeStackRequest and not pass it
- choosing "Close" from "File" menu - as it doesn't sent "closeStack"
The problem starts when user choose "Quit" from "myAppName" menu or type cmd-Q. Even if I have the handler for "Quit" in my "File" menu button, it sends "closeStack" message which I can't trap and cancel.
Any idea how to make "Quit" behaviour same as "Close" behaviour when build the app menu?
Marek
There is no problem if user quits by:
- pressing close window icon - as I can use closeStackRequest and not pass it
- choosing "Close" from "File" menu - as it doesn't sent "closeStack"
The problem starts when user choose "Quit" from "myAppName" menu or type cmd-Q. Even if I have the handler for "Quit" in my "File" menu button, it sends "closeStack" message which I can't trap and cancel.
Any idea how to make "Quit" behaviour same as "Close" behaviour when build the app menu?
Marek
Re: Quit vs Close stack
You can trap either the "shutdown" or "shutdownRequest" message. But is there a reason you can't just trap "closeStack"? That would allow you to use the same handler for both the Close menu item and the Quit item.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Quit vs Close stack
Jacque,
Unfortunately it's true what is mentioned in dictionary:
When I quit my app by cmd-Q or choose "myAppName" -> "Quit myAppName" from app menu - there is only "closeStack" message sent, no "closeStackRequest" which could break the quit or shutdown process. So I can't cancel closing the stack to give the user possibility to check internet connection or save his data in some other place.
It's on Mac OS 10.8.5 and any of LC versions. I didn't try it on Windows, but probably it's the same.
Marek.
Unfortunately it's true what is mentioned in dictionary:
The same is with "shutDown" message.The actual closing is not triggered by the closeStack message, so trapping the message and not allowing it to pass does not prevent the stack from closing. To prevent a stack from closing, trap the closeStackRequest message.
When I quit my app by cmd-Q or choose "myAppName" -> "Quit myAppName" from app menu - there is only "closeStack" message sent, no "closeStackRequest" which could break the quit or shutdown process. So I can't cancel closing the stack to give the user possibility to check internet connection or save his data in some other place.
It's on Mac OS 10.8.5 and any of LC versions. I didn't try it on Windows, but probably it's the same.
Marek.
Re: Quit vs Close stack
Hi Marek,
on Win 7 closeCard is trapped by alt+f4 so is closeStackRequest.
liveCode 6.1.2
Simon
on Win 7 closeCard is trapped by alt+f4 so is closeStackRequest.
liveCode 6.1.2
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Quit vs Close stack
OS X sends a 'quit" Apple event on Cmd-Q. Trap for that in an AppleEvent handler and you'll have your bases covered.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Quit vs Close stack
I misunderstood, I thought you wanted to perform an action before shutdown. I didn't notice you wanted to prevent quitting entirely. It looks like the shutdownRequest message would work though.snm wrote:Jacque,
Unfortunately it's true what is mentioned in dictionary:
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Quit vs Close stack
Richard,
I like your applescript hanger idea, but it doesn't work for me. I have the card script:
In both IDE and standalone after cmd-Q application quits without answering. The only difference is when opening standalone I receive the answer "aevt,lapp". But no any answer when quitting by cmd-Q or choose from the menu myAppName->Quit myAppName.
Is something wrong in this handler, or it doesn't work because of some bug?
Marek
I like your applescript hanger idea, but it doesn't work for me. I have the card script:
Code: Select all
on appleEvent pClass, pID
answer pClass, pId
--pass appleEvent
end appleEvent
Is something wrong in this handler, or it doesn't work because of some bug?
Marek