I have a TextInput()
widget that contains some default text.
When a user clicks inside the TextInput
, the text that was initially inside the TextInput
disappears (so that he can insert his own text without having to manually delete the default text).
- Is there an alternative way to replicate the above behavior? (e.g. some
already existing attribute of
TextInput
) - How can I make it reinsert automatically the text if the user didn't enter anything after clicking inside the
TextInput
and focused on some other widget. I triedon_unfocus: self.text = "(optionally add a description of the bug here)"
but there is nounfocus
attribute.
Code used:
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
Builder.load_string("""
<Main>:
Button:
text: 'Send bug report button'
TextInput:
never_selected: False
text: '(optionally add a description of the bug here)'
on_focus: if self.never_selected == False: self.text = ''; self.never_selected = True
""")
class Main(BoxLayout):
pass
if __name__ == '__main__':
from kivy.base import runTouchApp
runTouchApp(Main())
It's in the docs: hint_text property
It is a
StringProperty
, empty by default.