我使用Mac OS X 10.12 Sierra,Kivy 1.9.1,Python 2.7.3
修饰符不适用于以下代码:
#......
def __init__(self):
self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
self._keyboard.bind(on_key_down=self.on_key_down_cb)
def on_key_down_cb(self, keyboard, keycode, text, modifiers):
print(keycode)
print(text)
print(modifiers)
当我按“a”,“b”,“c”,HOLD“shift”和“a”,“b”,“c”
我期待abcABC (连接“文本”参数)
但输出是abcİabc
- 输出:
[INFO ] [Logger ] Record log in /Users/jares/.kivy/logs/kivy_17-02-07_50.txt
[INFO ] [Kivy ] v1.9.1
[INFO ] [Python ] v2.7.13 (default, Dec 18 2016, 07:03:39)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
[INFO ] [Factory ] 179 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_imageio, img_dds, img_gif, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO ] [OSC ] using <multiprocessing> for socket
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] OpenGL version <2.1 INTEL-10.18.65>
[INFO ] [GL ] OpenGL vendor <Intel Inc.>
[INFO ] [GL ] OpenGL renderer <Intel Iris Pro OpenGL Engine>
[INFO ] [GL ] OpenGL parsed version: 2, 1
[INFO ] [GL ] Shading version <1.20>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <16>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [Text ] Provider: sdl2
[INFO ] [GL ] NPOT texture support is available
[INFO ] [Base ] Start application main loop
(97, 'a')
a
[]
(98, 'b')
b
[]
(99, 'c')
c
[]
(304, 'shift')
İ
[]
(97, 'a')
a
['shift']
(98, 'b')
b
['shift']
(99, 'c')
c
['shift']
是否存在影响键盘行为的配置?
答案 0 :(得分:0)
解决方案:
使用on_textinput代替
Keyboard.bind(on_textinput=cb)