Reputation: 156
I'm editing a text of TextInput 'A' in Kivy application. I now need to copy text of TextInput 'B' to the A, by clicking on B, without A loosing it's focus.
Something like when I write an equation in Excel, I can click on another cell and the cell ID is copied to the equation, instead of selecting the another cell.
How would I do this, please?
Thanks.
Upvotes: 0
Views: 235
Reputation: 191
Not really sure if that is what you are looking for. If you click into the second TextInput
it will copy the content of the first TextInput
. I am using a main.py
# main.py
from kivy.app import App
from kivy.properties import StringProperty
class AnswerApp(App):
text_of_text_input_1 = StringProperty()
def change_text_of_text_input_2(self):
self.text_of_text_input_1 = self.root.ids.text_input_1.text
if __name__ == "__main__":
AnswerApp().run()
and the kv file answer.kv
.
# answer.kv
BoxLayout:
orientation: "vertical"
TextInput:
id: text_input_1
text: "text_input_1"
TextInput:
text: app.text_of_text_input_1
on_focus: app.change_text_of_text_input_2()
Upvotes: 1