Tab/Enter (and other keystrokes) handling in Kivy's TextInput widgets

前端 未结 4 1919
夕颜
夕颜 2021-02-05 13:53

I\'m writing an app using Kivy framework and I stumbled upon a minor but annoying problem: I don\'t know how to handle Tab/Enter/Arrow keys in text fields so that press

4条回答
  •  鱼传尺愫
    2021-02-05 13:59

    As suggested by Daniel Kinsman in his comment, you could subclass TextInput, add "previous" and "next" ObjectProperties for tab support (easy to set in kv using references to other widgets), and handle the keyboard events differently. There is no out of the box support for this right now, but if you want to work on such modification drop us a feature-request or comme discuss it in #kivy on freenode.

    https://github.com/kivy/kivy/blob/master/kivy/uix/textinput.py#L1188

    Maybe it would be even better to add such support on widget, and add some focus logic, so tab/enter have effects on any activable widget, and some widgets like slider use right/left/up/down keys too.

    So there is still a lot to do in Kivy about that, and if you are interested in helping, you can really make it happen faster, we'll help you :)

提交回复
热议问题