我想清除TextInput的text:,當我點擊它。示例代碼:from kivy.app import Appfrom kivy.lang import Builderkv_string = """ScreenManager: id: manager Screen: BoxLayout: orientation: 'vertical' Button: text: 'Why does it clear multiple inputs? And why do they get cleared after touch_up?' TextInput: text: 'Write Your Name' on_touch_down: self.text = '' TextInput: text: 'Write Your Last Name' on_focus: self.text = '' TextInput: text: 'Write Your Phone Number' on_touch_down: self.text = ''"""class MyApp(App): def build(self): root_widget = Builder.load_string(kv_string) return root_widgetif __name__ == "__main__": MyApp().run()無論是on_touch_down:或on_focus刪除只是目前專注文字輸入。相反,當我觸摸屏幕上的任何地方時,兩者都會被清除。一旦光標位于文本輸入上,我希望它們單獨清除。我也嘗試過,on_cursor但這也不起作用。我錯過了什么? 先感謝您!
添加回答
舉報
0/150
提交
取消