Not able to catch EVT_CLOSE in mac when app is closed from DOC

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
starightcircle
Earned a small fee
Earned a small fee
Posts: 12
Joined: Fri Sep 11, 2015 6:24 am

Not able to catch EVT_CLOSE in mac when app is closed from DOC

Post by starightcircle »

I am facing a problem in handling close event in MAC. I am catching EVT_CLOSE in my frame and do few things.
this event is caught when I press X button or closing the app from task bar in windows but in MAC this event
is caught only when I press X button of app not when it is closed from DOC buy using force quit.

Any idea how can i catch close event in this situation?
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Not able to catch EVT_CLOSE in mac when app is closed from DOC

Post by doublemax »

I don't much about OS X, but if that "force quit" is the same as killing the process through the task manager under Windows, there is no way to catch that.

You could try to catch the wxEVT_END_SESSION event, but i have my doubts it will fire in that situation.
http://docs.wxwidgets.org/trunk/classwx ... event.html
Use the source, Luke!
starightcircle
Earned a small fee
Earned a small fee
Posts: 12
Joined: Fri Sep 11, 2015 6:24 am

Re: Not able to catch EVT_CLOSE in mac when app is closed from DOC

Post by starightcircle »

Hi,

This gets caught in the App and by this time my frame destructor will be called and some listeners will be detatched. I wanted to catch the event my frame like in case of EVT_CLOSE.

Any idea how can check this in my frame before going for app exit?
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Not able to catch EVT_CLOSE in mac when app is closed from DOC

Post by doublemax »

Have you tried wxEVT_QUERY_END_SESSION? If it's sent, it should arrive before the frame is destroyed.
Use the source, Luke!
starightcircle
Earned a small fee
Earned a small fee
Posts: 12
Joined: Fri Sep 11, 2015 6:24 am

Re: Not able to catch EVT_CLOSE in mac when app is closed from DOC

Post by starightcircle »

Yes i tried now, But no end query session is not getting handled on quitting from doc, I have another question, Is it possible to make wxApp not quittable for some amount of time when we are doing something in the background?
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Not able to catch EVT_CLOSE in mac when app is closed from DOC

Post by doublemax »

Is it possible to make wxApp not quittable for some amount of time when we are doing something in the background?
Not that i know of.

I Googled about what "force quit" on OS X actually does and it seems its purpose is to kill unresponsive apps. If a user does this, he can't complain when the app doesn't exit gracefully.

Does the wxFrame destructor get called if an app gets killed like this? If yes, you could do some of the clean up there.
Use the source, Luke!
starightcircle
Earned a small fee
Earned a small fee
Posts: 12
Joined: Fri Sep 11, 2015 6:24 am

Re: Not able to catch EVT_CLOSE in mac when app is closed from DOC

Post by starightcircle »

Thanks doublemax for your timely help, Sorry for posting my response late.
I found this api OSXOnShouldTerminate. Which is part of out app.cpp. This gets called whenever the application is closed from the doc in mac
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Not able to catch EVT_CLOSE in mac when app is closed from DOC

Post by ONEEYEMAN »

Hi,
You can prepare and submit a patch to the trac.wxwidgets.org or make a PR on github.
Then you will guarantee that this function will be in the library and it will be less maintenance for you code.

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Not able to catch EVT_CLOSE in mac when app is closed from DOC

Post by doublemax »

@ONEEYEMAN

It is in wxWidgets, but apparently undocumented.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Not able to catch EVT_CLOSE in mac when app is closed from DOC

Post by ONEEYEMAN »

@doublemax,
Again - patches welcome. ;-)
Post Reply