caretPosition

open override fun caretPosition(text: CharSequence, x: Float, indentationColumns: Int): Int

Calculate the carat position (0..text.length inclusive) for a given x in pixels for a given text.

The current implementation is very inefficient when text is long - O(n²). But for simple text fields, this should be sufficient.