The Source for Java Technology Collaboration

Home » java.net Forums » General Desktop Discussions » General Desktop Issues & Discussion

Thread: mac application quit (commad+Q) bypassing appframework shutdown() method

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 3 - Last Post: Apr 8, 2008 8:13 PM by: alavideo Threads: [ Previous | Next ]
alavideo

Posts: 17
mac application quit (commad+Q) bypassing appframework shutdown() method
Posted: Apr 7, 2008 7:29 PM
 
  Click to reply to this thread Reply

Hello,
I'm sure this has been asked before but searching this forum didn't turn up any results. What is the solution for getting the application framework to call the framework's "shutdown()" method when using the mac's application quit keyboard shortcut (command+Q)? The appframework automatically adds the proper keyboard shortcut to the "exit" menu, but using the shortcut just seems to exit the app without calling the framework shutdown() method. Any help would be much appreciated.

Regards,
Jim

lmineiro

Posts: 13
Re: mac application quit (commad+Q) bypassing appframework shutdown() metho
Posted: Apr 8, 2008 7:26 AM   in response to: alavideo
 
  Click to reply to this thread Reply

Hi,

Check http://developer.apple.com/samplecode/OSXAdapter/index.html and see if you can plug a call to the shutdown() method to the Adapter quit method.

Hope it helps.

alavideo

Posts: 17
Re: mac application quit (commad+Q) bypassing appframework shutdown() metho
Posted: Apr 8, 2008 8:13 PM   in response to: lmineiro
 
  Click to reply to this thread Reply

Imineiro,
That link was EXACTLY what I needed. I was able to take the sample code and incorporate it into the appframework in just a matter of minutes! Now the cmd-Q event properly lets the app framework's exit() method handle the quit/shutdown.

Thanks!
Jim

ntdaley

Posts: 1
Re: mac application quit (commad+Q) bypassing appframework shutdown() metho
Posted: Apr 8, 2008 10:06 AM   in response to: alavideo
 
  Click to reply to this thread Reply

I presume you're using the com.apple.eawt library.

Have you registered an ApplicationListener?
Does its handleQuit method call the event's setHandled method?

As I recall it, if you don't have an ApplicationListener registered, it will default to calling System.exit().

If you have registered an ApplicationListener, then if the ApplicationEvent's handled property is set to true, then it will (again) call System.exit().

To cancel exit, or to handle it in your own way, you will need an ApplicationListener, and it's handleQuit method should NOT call event.setHandled( true ).




 XML java.net RSS