TextFieldValue
@Immutable class TextFieldValue
kotlin.Any | |
↳ | androidx.compose.ui.text.input.TextFieldValue |
A class holding information about the editing state.
The input service updates text selection, cursor, text and text composition. This class represents those values and it is possible to observe changes to those values in the text editing composables.
This class stores a snapshot of the input state of the edit buffer and provide utility functions for answering IME requests such as getTextBeforeCursor, getSelectedText.
Input service composition is an instance of text produced by IME. An example visual for the composition is that the currently composed word is visually separated from others with underline, or text background. For description of composition please check W3C IME Composition.
IME composition is defined by composition parameter and function. When a TextFieldValue with null composition is passed to a TextField, if there was an active composition on the text, the changes will be applied. Applying a composition will accept the changes that were still being composed by IME. Please use copy functions if you do not want to intentionally apply the ongoing IME composition.
Summary
Public constructors | |
---|---|
<init>(annotatedString: AnnotatedString, selection: TextRange = TextRange.Zero, composition: TextRange? = null) A class holding information about the editing state. |
Public methods | |
---|---|
TextFieldValue |
copy(annotatedString: AnnotatedString = this.annotatedString, selection: TextRange = this.selection, composition: TextRange? = this.composition) Returns a copy of the TextFieldValue. |
TextFieldValue |
copy(text: String, selection: TextRange = this.selection, composition: TextRange? = this.composition) Returns a copy of the TextFieldValue. |
Boolean | |
Int |
hashCode() |
String |
toString() |
Extension functions | ||||||
---|---|---|---|---|---|---|
From androidx.compose.ui.text.input
|
Properties | |
---|---|
AnnotatedString |
the text to be rendered. |
TextRange? |
Composition range created by IME. |
TextRange |
The selection range. |
String |
Companion properties | |
---|---|
Saver<TextFieldValue, Any> |
The default Saver implementation for TextFieldValue. |
Public constructors
<init>
TextFieldValue(
text: String = "",
selection: TextRange = TextRange.Zero,
composition: TextRange? = null)
Parameters | |
---|---|
text: String = "" | the text to be rendered. |
selection: TextRange = TextRange.Zero | the selection range. If the selection is collapsed, it represents cursor location. When selection range is out of bounds, it is constrained with the text length. |
composition: TextRange? = null | the composition range, null means empty composition or apply if a composition exists on the text. Owned by IME, and if you have an instance of TextFieldValue please use copy functions if you do not want to intentionally change the value of this field. |
<init>
TextFieldValue(
annotatedString: AnnotatedString,
selection: TextRange = TextRange.Zero,
composition: TextRange? = null)
A class holding information about the editing state.
The input service updates text selection, cursor, text and text composition. This class represents those values and it is possible to observe changes to those values in the text editing composables.
This class stores a sn