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

前端 未结 4 1920
夕颜
夕颜 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 14:07

    Kivy 1.9 provides the ability to set write_tab: False on text inputs (see docs), causing the tab key to focus on the next focusable widget.

    Kivy allows the Enter key to dispatch events by setting multiline: False and on_text_validate: root.foo().

    So, to create a text input widget that has the desired Enter and Tab functionality, do as follows:

    TextInput:
        write_tab: False
        multiline: False
        on_text_validate: root.foo()
    

提交回复
热议问题