Raj Narayanan
Raj Narayanan

Reputation: 3432

How to disable direct input in Textfield with DropdownMenu composable?

While using a DropdownMenu composable with a Textfield, how do I prevent the user from directly typing into the Textfield?

Setting the field's enabled parameter to false completely deactivates the field which is not desired.

Upvotes: 3

Views: 860

Answers (1)

Thracian
Thracian

Reputation: 67039

TextField has a parameter called readOnly, you can set it to true to prevent it from being modified.

readOnly controls the editable state of the TextField. When true, the text field can not be modified, however, a user can focus it and copy text from it. Read-only text fields are usually used to display pre-filled forms that user can not edit

Upvotes: 4

Related Questions