This commit is contained in:
yumoqing 2020-11-13 21:56:44 +08:00
parent 14e60b3430
commit 3ae357bbb1
2 changed files with 7 additions and 30 deletions

View File

@ -43,21 +43,7 @@ class BoxViewer(WidgetReady, BoxLayout):
kwargs = {k:v for k,v in options.items() if k not in remind } kwargs = {k:v for k,v in options.items() if k not in remind }
BoxLayout.__init__(self, orientation='vertical', **kwargs) BoxLayout.__init__(self, orientation='vertical', **kwargs)
WidgetReady.__init__(self) WidgetReady.__init__(self)
self.used_keys = [ self.use_keyboard()
{
"keyname":"enter",
"modifiers":[]
},
{
"keyname":"up",
"modifiers":[]
},
{
"keyname":"down",
"modifiers":[]
},
]
self.use_keyboard(self.used_keys)
self.selected_data = None self.selected_data = None
self.options = options self.options = options
self.box_width = CSize(options['boxwidth']) self.box_width = CSize(options['boxwidth'])

View File

@ -70,21 +70,12 @@ class WidgetReady(EventDispatcher):
return False return False
# Keycode is composed of an integer + a string # Keycode is composed of an integer + a string
# If we hit escape, release the keyboard # If we hit escape, release the keyboard
if keycode[1] == 'escape': keyinfo = {
keyboard.release() "keyname":keycode[1],
"modifiers":modifiers
for ki in self.keyinfos: }
if ki['keyname'] == keycode[1] and listequal(ki['modifiers'],modifiers): self.dispatch('on_key_down',keyinfo)
keyinfo = { return True
"keyname":keycode[1],
"modifiers":modifiers
}
self.dispatch('on_key_down',keyinfo)
return True
# Return True to accept the key. Otherwise, it will be used by
# the system.
return False
def on_fullscreen(self, instance, value): def on_fullscreen(self, instance, value):
window = self.get_parent_window() window = self.get_parent_window()