comparison 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
comparison
equal deleted inserted replaced
356:307c2501d8b2 357:4d3a0c4f2430
33 """Base class to handle platform specific behaviours""" 33 """Base class to handle platform specific behaviours"""
34 34
35 def init_platform(self): 35 def init_platform(self):
36 # we don't want multi-touch emulation with mouse 36 # we don't want multi-touch emulation with mouse
37 37
38 # this option doesn't make sense on Android and cause troubles, so we only activate 38 # this option doesn't make sense on Android and cause troubles, so we only
39 # it for other platforms (cf. https://github.com/kivy/kivy/issues/6229) 39 # activate it for other platforms (cf. https://github.com/kivy/kivy/issues/6229)
40 KivyConfig.set('input', 'mouse', 'mouse,disable_multitouch') 40 KivyConfig.set('input', 'mouse', 'mouse,disable_multitouch')
41 41
42 def on_app_build(self, wid): 42 def on_app_build(self, wid):
43 pass 43 pass
44 44
54 def on_resume(self): 54 def on_resume(self):
55 pass 55 pass
56 56
57 def on_stop(self): 57 def on_stop(self):
58 pass 58 pass
59
60 def on_key_back_root(self):
61 """Back key is called while being on root widget"""
62 return True
63
64 def on_key_back_share(self, share_widget):
65 """Back key is called while being on share widget"""
66 share_widget.close()
67 return True
59 68
60 def open_url(self, url, wid=None): 69 def open_url(self, url, wid=None):
61 """Open an URL in the way appropriate for the platform 70 """Open an URL in the way appropriate for the platform
62 71
63 @param url(str): URL to open 72 @param url(str): URL to open