[英]changing textinput text when clicked in a kv file
當用戶單擊它時,我試圖更改文本輸入的文本。 我嘗試了 def on_enter,但在整個文件中我使用了一個屏幕,所以這就是窗口。
def test(self, *args):
self.ids.text_input.text = "test"
#self.ids.text_input.bind(on_text_validate = self.test)?
TextInput:
multiline: False
id: text_input
text:'00:00'
on_enter: app.test() #? problem area
on_press: app.test() #? problem area
您可以使用on_focus
代替on_enter
或on_press
:
TextInput:
multiline: False
id: text_input
text:'00:00'
on_focus: app.test(self) # call app.test() and pass reference to the TextInput
那么App
中的方法可以是:
def test(self, ti):
ti.text = "test"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.