简体   繁体   中英

How can I get the position of a cursor in Kivy?

I have to slice the 2 seperate strings according to the position of the cursor in the textinput. And this is what I've tried. (text_box is a textinput property.)

text_box = ObjectProperty()

x,y = self.text_box.cursor

But then, I found that x, y position is not stable, and keep on changing whenever I click other position.

Is there anyway I can find a stable cursor position information from Kivy?

Also, is there a thing like on_click in textinput instead of on_focus? (so I can check the cursor position whenever I click the textinput.)

Well, text_box.cursor did not work in on_focus

but it works fine in on_touch_up .

I am not sure why is that. But at least now I can make it to work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM