Add info on sending quit requests properly in Handling quit requests (#4911)

Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
This commit is contained in:
insomniac_lemon
2021-05-14 15:44:40 -04:00
committed by GitHub
parent 49022c2e65
commit ea1ae27270

View File

@@ -59,3 +59,24 @@ behavior to quit when quit is requested, this can be changed:
.. code-tab:: csharp
GetTree().SetAutoAcceptQuit(false);
Sending your own quit notification
----------------------------------
While forcing the application to close can be done by calling :ref:`SceneTree.quit <class_SceneTree_method_quit>`,
doing so will not send the quit *notification*. This means the function
described above won't be called. Quitting by calling
:ref:`SceneTree.quit <class_SceneTree_method_quit>` will not allow custom actions
to complete (such as saving, confirming the quit, or debugging), even if you try
to delay the line that forces the quit.
Instead, you should send a quit request:
.. tabs::
.. code-tab:: gdscript GDScript
get_tree().notification(MainLoop.NOTIFICATION_WM_QUIT_REQUEST)
.. code-tab:: csharp
GetTree().Notification(MainLoop.NotificationWmQuitRequest)