data class TypingContext
It’s important to note that the cursorStart and cursorEnd refer to the character position of the cursor in the text, as reflected by the following examples (where the character | marks the position(s) of the cursor):
Take into account that these positions do not always match the selectionStart
and selectionEnd
of the EditText, specially whe there are special characters such as emoji, diacritics, etc.
Constructors | |
---|---|
TypingContext(context: String) | |
TypingContext(context: String, cursor: Int) | |
TypingContext(context: String, cursorStart: Int, cursorEnd: Int) |
Properties | |
---|---|
String |
context The text context. |
Int |
cursorStart The position of the start of the cursor with respect to the context. |
Int |
cursorEnd The position of the end of the cursor with respect to the context. |
TypingContext(context: String)
Parameters | |
---|---|
context: String | The text context. |
TypingContext(context: String, cursor: Int)
Initializes the TypingContext with the cursor position.
Example: “Hello |wrld” => context=“Hello wrld”, cursor=6.
Parameters | |
---|---|
context: String | The text context. |
cursor: Int | The position of the cursor with respect to the ‘context’. |
TypingContext(context: String, cursorStart: Int, cursorEnd: Int)
Initializes the ‘TypingContext’ allowing a selection of a substring in the text context.
Example: “Hello |wrld|” => context=“Hello wrld”, cursorStart=6, cursorEnd=10. This means that “wrld” is selected.
Parameters | |
---|---|
context: String | The text context. |
cursorStart: Int | The position of the start of the cursor with respect to the context. |
cursorEnd: Int | The position of the end of the cursor with respect to the context. |
val context: String
The text context.
var cursorStart: Int = context.length
The position of the start of the cursor with respect to the context.
var cursorEnd: Int = context.length
The position of the end of the cursor with respect to the context. cursorEnd should always be greater than or equal to cursorStart.