tabs - Kivy:Shift+Tab 不适用于 TextInput
问题描述
我试图通过按 Shift+Tab 向后循环通过我的 TextInputs(我知道没什么特别的)。我只是不知道如何让它工作。它总是跳到下一个 TextInput。我在谷歌上没有找到任何东西。
此外,我希望在焦点 = True 时选择整个 TextInput.text。也没有让它正常工作。
请帮帮我:-D
这是我的最小示例顺便说一句:
import kivy
kivy.require('1.11.0')
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_string('''
<CustomInput@TextInput>:
text: "Blindtext"
size_hint_y: 0.1
pos_hint: {"center_y": 0.5}
multiline: False
write_tab: False
<Box>:
padding: 20,0,20,0
spacing: 10
CustomInput
CustomInput
CustomInput
''')
class Box(BoxLayout):
pass
class TestApp(App):
def build(self):
return Box()
if __name__ == "__main__":
TestApp().run()
高度赞赏!干杯,smarwin
解决方案
用这篇文章解决了这个问题:https ://github.com/kivy/kivy/issues/6560
您必须在 focus.py 的keyboard_on_key_down 方法中更改该if ['shift'] == modifiers:
行。if modifiers == {'shift'}:
您将在 uix/behaviors/ 的 kivy 文件夹中找到此文件。
def keyboard_on_key_down(self, window, keycode, text, modifiers):
if keycode[1] == 'tab': # deal with cycle
if ['shift'] == modifiers:
next = self.get_focus_previous()
else:
next = self.get_focus_next()
if next:
self.focus = False
next.focus = True
return True
return False
没有保证,但到目前为止它对我来说效果很好。干杯,smarwin
推荐阅读
- vue.js - VueJs - 使用数组中的数据创建所有周的卡片
- graphql - 第三方 API 的 Gatsby 插件抛出错误
- python - AttributeError:“列表”对象没有属性“dist”
- wcf - 如何在不指定 FaultContractAttribute 的情况下使用带有详细信息的 FaultException
- macos - WebKitWebProcess 制作新的停靠图标
- python - 如何在 Python 中进行并行处理?
- node.js - 无法在 Nodejs 中连接本地 PostgreSQL 数据库
- java - 如何在 RecyclerView 中显示同一联系人的多个电话号码?
- apache-kafka - 使用 kafka 流尝试将消息从输入主题写入输出主题
- r - 我的 R 函数旨在将参与者随机分配到组并模拟手段差异,但并未通过管道运行