Android Question Coordinates x,y of a cursor IN A VIEW

jotaele

Member
Licensed User
Longtime User
Hi:

I need to obtain the x,y of the focus in a view.

For example, in a EditText, if you write a word like HELP and you put the cursor in the midle, like HE_LP, I need to obtain the coordinates x,y of the cursor at this moment (The coordinates x,y at position _).

I know that its posible obtain the position in a EditText (character 1,2,3,4,...) but I need the coordinates x,y.

Is it posible?

Thanks a lot.
 

jotaele

Member
Licensed User
Longtime User
I think you can simply use a touch gesture to get the cooridantes when clicking on the textview

Yes, but when you write in the EditText, the cursor changes the position and the coordinates change.

I need to obtain the coordinates of the typical verticar bar (the indicator that you are typing in that position).

I have an object like an EditText, but its not an EditText.
 
Upvote 0

narek adonts

Well-Known Member
Licensed User
Longtime User
If you are not touching the editbox the cursor is automaticaly at the end. So editbox.left + editbox.text.measuretextwidth.
When the user change the cursor manualy the x will change to the touch gesture x.
I dont know if I explained correctely.

Narek
 
Upvote 0

jotaele

Member
Licensed User
Longtime User
If you are not touching the editbox the cursor is automaticaly at the end. So editbox.left + editbox.text.measuretextwidth.
When the user change the cursor manualy the x will change to the touch gesture x.
I dont know if I explained correctely.

Narek

Yes, but I think that you dont understand me.

The object is EmojiEditText and it has not all the methods of EditText. @DonManfred wrapped the library, but for any reason, the inheritance in the library is incomplete.

I want to catch the position of the cursor and simulate a click when I insert an new icon.

This is the thread:

https://www.b4x.com/android/forum/threads/msemoji-v1-0-0.53787/#content
 
Upvote 0
Top