Quiting out of Run() and Exit()

edited April 2017 in Help request
Curious to know how to deal with the following:

While in Run() I can check a keyboard shortcut for Yes/No to see if the user wants to quit, perform some kind of tidy up, eg: save something to a file, then return orxSTATUS_FAILURE it order to trigger an exit.

Then Exit() will be hit.

But I notice that if you click the window close gadget, or (under windows) Alt-F4, then only the Exit() function is triggered.

There doesn't seem to be a way to detect a close event, allow the user to be presented with a choice to cancel the close.

It could be that Orx is not able to tie in that intimately with the parent window system?

This isn't a deal breaker but would be good to have all ways of closing an application do the same thing or to cancel a close.

Comments

  • edited April 2017
    Another way to quit is to listen to the system event orxSYSTEM_EVENT_CLOSE.
    This event will be sent when the user closes the window with Alt-F4/X button. However there's no way to ignore it as GLFW handles it on its side without letting orx make a decision.
    That has changed with GLFW 3.x, where the decision can be delegated to the application (in our case orx and the user).

    Until then, if you need a single notification point that is not the Exit() function, you could send this event yourself from within the Run() function and set a flag somewhere when handling it (similar to what orx launcher does in orxMain.c).

    I guess I could see to modify the helper to send this event when Run() returns orxSTATUS_FAILURE and it'll be the users' responsibility to make sure they don't send the event multiple times.
  • edited April 2017
    I think for now, the autosave function I have can sit in Exit() so that it works no matter how you quit.

    But for now the user can only get the "Are you sure you want to quit?" dialog if they use the keyboard shortcut to exit.

    (That was an easier explanation :) )

    This will be fine for now, I'll wait to try out GLFW 3.
Sign In or Register to comment.