Kivy: Borrar entrada de texto con 'on focus' o 'on_touch_down'
Quiero borrar unTextInput
'stext:
cuando hago clic en él. Código de muestra
from kivy.app import App
from kivy.lang import Builder
kv_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_widget
if __name__ == "__main__":
MyApp().run()
Ningunoon_touch_down:
oon_focus
borra SOLO la entrada de texto que está enfocada actualmente. En cambio, ambos se borran cuando toco cualquier parte de la pantalla. Me gustaría que se borren individualmente una vez que el cursor esté en una entrada de texto. También probéon_cursor
pero eso tampoco funcionó. ¿Qué me estoy perdiendo? @¡Gracias de antemano