InputConnection.commitText is replacing the whole text instead of concatenation

54 Views Asked by At

I am creating my own custom keyboard and I am point the keyboard to the EditText using etInputData.onCreateInputConnection(EditorInfo())!!. In my layout, I've used Custom TextView and when user clicks on the TextView, I use InputConnection to commitText but instead of concatenating the text and moving the cursor position, it replaces all text as shown in the following images: enter image description here

enter image description here

Following is the commitText code on user click:

override fun onClick(v: View?) {
    if (!::inputConnection.isInitialized) return

    val value = (v as TextView).text.toString()
    inputConnection.commitText(value, 1)
}
0

There are 0 best solutions below