1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-16 14:00:40 +00:00

Created tutorial_quit (markdown)

reduz
2014-06-23 05:12:20 -07:00
parent 07f9fd9f26
commit 406ee89acb

26
tutorial_quit.md Normal file

@@ -0,0 +1,26 @@
# Handling Quit Request
## 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 titlebar. On Android, the back button is used to quit when on the main screen (and to go back otherwise).
## Handling the Notification
The [MainLoop](class_mainloop) has a special notification that is sent to all nodes when quit is requested: MainLoop.NOTIFICATION_WM_QUIT.
Handling it is done as follows (on any node):
```python
func _notification(what):
if (what==MainLoop.NOTIFICATION_WM_QUIT_REQUEST):
get_scene().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, this can be changed:
```python
get_scene().set_auto_accept_quit(false)
```