diff cagou/core/platform_/base.py @ 357:4d3a0c4f2430

core: better back key (ESC) management: - back key (which is mapped to esc keycode by SDL2 backend) is now handler with a platform specific method when on root widget (i.e. a default widget is selected, or nothing is selected). Default behaviour is to do nothing, while on Android the app is put to background - CagouWidget now has a default key_input method which go back to default widget.
author Goffi <goffi@goffi.org>
date Sat, 18 Jan 2020 23:12:52 +0100
parents 83697218b9b2
children 1a12bbd80943
line wrap: on
line diff
--- a/cagou/core/platform_/base.py	Fri Jan 17 20:35:57 2020 +0100
+++ b/cagou/core/platform_/base.py	Sat Jan 18 23:12:52 2020 +0100
@@ -35,8 +35,8 @@
     def init_platform(self):
         # we don't want multi-touch emulation with mouse
 
-        # this option doesn't make sense on Android and cause troubles, so we only activate
-        # it for other platforms (cf. https://github.com/kivy/kivy/issues/6229)
+        # this option doesn't make sense on Android and cause troubles, so we only
+        # activate it for other platforms (cf. https://github.com/kivy/kivy/issues/6229)
         KivyConfig.set('input', 'mouse', 'mouse,disable_multitouch')
 
     def on_app_build(self, wid):
@@ -57,6 +57,15 @@
     def on_stop(self):
         pass
 
+    def on_key_back_root(self):
+        """Back key is called while being on root widget"""
+        return True
+
+    def on_key_back_share(self, share_widget):
+        """Back key is called while being on share widget"""
+        share_widget.close()
+        return True
+
     def open_url(self, url, wid=None):
         """Open an URL in the way appropriate for the platform