Skip to content

Fix Handling Quit Requests wording about mobile platforms #8980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions tutorials/inputs/handling_quit_requests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Quitting

Most platforms have the option to request the application to quit. On
desktops, this is usually done with the "x" icon on the window title bar.
On Android, the back button is used to quit when on the main screen (and
to go back otherwise).
On mobile devices, the app can quit at any time while it is suspended
to the background.

Handling the notification
-------------------------
Expand All @@ -18,16 +18,6 @@ On desktop and web platforms, :ref:`Node <class_Node>` receives a special
``NOTIFICATION_WM_CLOSE_REQUEST`` notification when quitting is requested from
the window manager.

On Android, ``NOTIFICATION_WM_GO_BACK_REQUEST`` is sent instead.
Pressing the Back button will exit the application if
**Application > Config > Quit On Go Back** is checked in the Project Settings
(which is the default).

.. note::

``NOTIFICATION_WM_GO_BACK_REQUEST`` isn't supported on iOS, as
iOS devices don't have a physical Back button.

Handling the notification is done as follows (on any node):

.. tabs::
Expand All @@ -45,9 +35,6 @@ Handling the notification is done as follows (on any node):
GetTree().Quit(); // default behavior
}

When developing mobile apps, quitting is not desired unless the user is
on the main screen, so the behavior can be changed.

It is important to note that by default, Godot apps have the built-in
behavior to quit when quit is requested from the window manager. This
can be changed, so that the user can take care of the complete quitting
Expand All @@ -62,6 +49,22 @@ procedure:

GetTree().AutoAcceptQuit = false;

On mobile devices
-----------------

There is no direct equivalent to ``NOTIFICATION_WM_CLOSE_REQUEST`` on mobile
platforms. Due to the nature of mobile operating systems, the only place
that you can run code prior to quitting is when the app is being suspended to
the background. On both Android and iOS, the app can be killed while suspended
at any time by either the user or the OS. A way to plan ahead for this
possibility is to utilize ``NOTIFICATION_APPLICATION_PAUSED`` in order to
perform any needed actions as the app is being suspended.

On Android, pressing the Back button will exit the application if
**Application > Config > Quit** On Go Back is checked in the Project Settings
(which is the default). This will fire ``NOTIFICATION_WM_GO_BACK_REQUEST``.


Sending your own quit notification
----------------------------------

Expand Down