Created
October 19, 2021 21:44
-
-
Save victorbrndls/9c9753e86f6fc226c37c8c94cc1e40f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val focusRequester = remember { FocusRequester() } | |
var color by remember { mutableStateOf(Black) } | |
Box( | |
Modifier | |
.clickable { focusRequester.requestFocus() } | |
.border(2.dp, color) | |
// The focusRequester should be added BEFORE the focusable. | |
.focusRequester(focusRequester) | |
// The onFocusChanged should be added BEFORE the focusable that is being observed. | |
.onFocusChanged { color = if (it.isFocused) Green else Black } | |
.focusable() | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment