changeset 349:33244f944bd8

core: "key_input" method is now checked and used if suitable in selected widget.
author Goffi <goffi@goffi.org>
date Fri, 17 Jan 2020 18:44:35 +0100
parents 38fd457b2158
children 1ac40d3121f6
files cagou/core/cagou_main.py cagou/plugins/plugin_wid_remote.py
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/core/cagou_main.py	Fri Jan 17 18:44:32 2020 +0100
+++ b/cagou/core/cagou_main.py	Fri Jan 17 18:44:35 2020 +0100
@@ -342,6 +342,14 @@
         return local_platform.on_stop()
 
     def key_input(self, window, key, scancode, codepoint, modifier):
+
+        # we first check if selected widget handles the key
+        if ((self.host.selected_widget is not None
+             and hasattr(self.host.selected_widget, 'key_input')
+             and self.host.selected_widget.key_input(window, key, scancode, codepoint,
+                 modifier))):
+            return True
+
         if key == 27:
             # we disable [esc] handling, because default action is to quit app
             return True
--- a/cagou/plugins/plugin_wid_remote.py	Fri Jan 17 18:44:32 2020 +0100
+++ b/cagou/plugins/plugin_wid_remote.py	Fri Jan 17 18:44:35 2020 +0100
@@ -34,7 +34,6 @@
 from kivy.uix.label import Label
 from kivy.uix.boxlayout import BoxLayout
 from kivy.uix.floatlayout import FloatLayout
-from kivy.core.window import Window
 from cagou import G
 from functools import partial
 
@@ -187,7 +186,6 @@
         cagou_widget.CagouWidget.__init__(self)
         FilterBehavior.__init__(self)
         TouchMenuBehaviour.__init__(self)
-        Window.bind(on_keyboard=self.key_input)
         self.stack_layout = None
         self.showRootWidget()