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 }
BoxLayout.__init__(self, orientation='vertical', **kwargs)
WidgetReady.__init__(self)
self.used_keys = [
{
"keyname":"enter",
"modifiers":[]
},
{
"keyname":"up",
"modifiers":[]
},
{
"keyname":"down",
"modifiers":[]
},
]
self.use_keyboard(self.used_keys)
self.use_keyboard()
self.selected_data = None
self.options = options
self.box_width = CSize(options['boxwidth'])

View File

@ -70,21 +70,12 @@ class WidgetReady(EventDispatcher):
return False
# Keycode is composed of an integer + a string
# If we hit escape, release the keyboard
if keycode[1] == 'escape':
keyboard.release()
for ki in self.keyinfos:
if ki['keyname'] == keycode[1] and listequal(ki['modifiers'],modifiers):
keyinfo = {
"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
keyinfo = {
"keyname":keycode[1],
"modifiers":modifiers
}
self.dispatch('on_key_down',keyinfo)
return True
def on_fullscreen(self, instance, value):
window = self.get_parent_window()