Switching Archor Selection using android ime
Asked Answered
I

0

6

I am trying to design a custom keyboard and a part of the keyboard is to allow the user to select some text and edit it. I wanted to provide the ability to the user to be able to switch selection of the anchor so that he/she may be able to expand/shrink the selection from either end of the selection.

Till now I have been passing the simple ctrl-a/shift-arrowkey to allow the user to do so, But using this method I have no way of switching the selection anchor, none that I know of.

I have tried to play around with the Selection class available in the android api, but to no avail. I initially thought of swaping the Selection.SELECT_END and Selection.SELECT_START variables might do the trick, but then I realized those are final variables and hence a dead-end. There exists a method named setSelection(Spannable text, int start, int stop) in the Selection class, but I am not able to make sense of the parameter "Spannable text". What is it? and where do I get it from?

So the question is, how can I make this happen?

The keyboard I am developing is open-source and if you need to check the code to understand any part of the question, you can visit the code here

Insufflate answered 31/8, 2018 at 5:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.