This commit is contained in:
yumoqing 2020-11-13 22:25:08 +08:00
parent 5b1421dc21
commit 7c9750ec54
2 changed files with 8 additions and 25 deletions

View File

@ -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)

View File

@ -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):