From 406ee89acb9664b51df028361884de0abf49fa29 Mon Sep 17 00:00:00 2001 From: reduz Date: Mon, 23 Jun 2014 05:12:20 -0700 Subject: [PATCH] Created tutorial_quit (markdown) --- tutorial_quit.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tutorial_quit.md diff --git a/tutorial_quit.md b/tutorial_quit.md new file mode 100644 index 0000000..11a338e --- /dev/null +++ b/tutorial_quit.md @@ -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) +``` +