-
Notifications
You must be signed in to change notification settings - Fork 112
Add an extension on TextController that returns a mutable state of TextFieldValue
#1299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an extension on TextController that returns a mutable state of TextFieldValue
#1299
Conversation
…xtFieldValue This makes it easy to use it with text fields while persisting selection state.
|
|
|
As I understand it, the primary purpose of If you only care about var foo by fooTextController.asMutableTextFieldValueState()
doStuff(foo.text) // StringAlso, I think you mostly care about wanting a var foo by fooTextController.asMutableTextFieldValueState()
SomeTextField(
value = foo.text,
onValueChanged = { newString -> foo = TextFieldValue(newString, TextRange(newString.length)) }
)I admit ☝️ is less ergonomic, but I imagine there are very few use cases like that. |
|
That all makes sense to me.
|
done! |
|
You'll need to update the api spec: |
Thanks! forgot about that. |
|
Sorry the CI jobs weren't running, they should from now on. |
While
asMutableState()extension already exists, it works withStringand does not preserve selection ranges.TextController.asMutableTextFieldValueState()returns a mutable state ofTextFieldValue, making it easy to integrateTextControllerwith text fields.