From 7c9750ec54f6a3d26afe364046f5c115f463592b Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 13 Nov 2020 22:25:08 +0800 Subject: [PATCH] bugfix --- kivyblocks/boxViewer.py | 13 ++++--------- kivyblocks/ready.py | 20 ++++---------------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/kivyblocks/boxViewer.py b/kivyblocks/boxViewer.py index 5484513..ed1c751 100644 --- a/kivyblocks/boxViewer.py +++ b/kivyblocks/boxViewer.py @@ -69,7 +69,10 @@ class BoxViewer(WidgetReady, BoxLayout): self.viewContainer.bind(size=self.resetCols, pos=self.resetCols) self.viewContainer.bind(on_scroll_stop=self.on_scroll_stop) - # self.use_keyboard() + self.use_keyboard() + + def key_handle(self,keyinfo): + print('keyinfo=',keyinfo,'...................') def getParams(self,o,p): self.params = p @@ -116,14 +119,6 @@ class BoxViewer(WidgetReady, BoxLayout): self.dataloader.loadPage(1) self.initflag = True - def on_key_down(self,keyinfo): - if keyinfo['keyname'] == 'enter': - self.selected_box.on_press() - if keyinfo['keyname'] == 'down': - print('down key entried') - if keyinfo['keyname'] == 'up': - print('up key entried') - def showObject(self, holders, rec,index=0): def doit(self,holders,idx,o,w): w.bind(on_press=self.select_record) diff --git a/kivyblocks/ready.py b/kivyblocks/ready.py index 593906a..baced5c 100644 --- a/kivyblocks/ready.py +++ b/kivyblocks/ready.py @@ -15,19 +15,10 @@ class WidgetReady(EventDispatcher): def __init__(self): self.register_event_type('on_ready') - self.register_event_type('on_key_down') self._ready = False def on_ready(self): pass - def on_key_down(self,keyinfo): - """ - keyinfo is a dict with: - keyname - modifiers - keys - """ - print(kinfo) def ready(self): if self._ready: @@ -40,12 +31,6 @@ class WidgetReady(EventDispatcher): self.ready() def use_keyboard(self): - """ - keyinfos is a list of aceepted keys keyinfo - if the on_key_down's key is one of the keyinfos, - fire a event, and return True, - else just return False - """ self.my_kb = Window.request_keyboard(None, self) if not self.my_kb: print('my_kb is None........') @@ -54,6 +39,9 @@ class WidgetReady(EventDispatcher): if self.my_kb.widget: self.my_kb.set_mode_free() + def key_handle(self,keyinfo): + pass + def _on_keyboard_down(self, keyboard, keycode, text, modifiers): print('The key', keycode, 'have been pressed') print(' - text is %r' % text) @@ -62,7 +50,7 @@ class WidgetReady(EventDispatcher): "keyname":keycode[1], "modifiers":modifiers } - self.dispatch('on_key_down',keyinfo) + self.key_handle(keyinfo) return True def on_fullscreen(self, instance, value):