Daniele B
07/07/2023, 8:01 AMAlexander Maryanovsky
07/07/2023, 11:55 AMIndication
or just change the background on pointer enter/exit events:
@OptIn(ExperimentalComposeUiApi::class)
fun main() = singleWindowApplication {
var background by remember { mutableStateOf(Color.Blue) }
Button(
onClick = { },
colors = ButtonDefaults.buttonColors(
backgroundColor = background
),
modifier = Modifier
.onPointerEvent(PointerEventType.Enter) {
background = Color.Red
}
.onPointerEvent(PointerEventType.Exit) {
background = Color.Blue
}
) {
Text("Button")
}
}
Daniele B
07/07/2023, 1:02 PMLouis Pullen-Freilich [G]
07/07/2023, 1:13 PMAlexander Maryanovsky
07/07/2023, 1:16 PMfun main() = singleWindowApplication {
val interactionSource = remember { MutableInteractionSource() }
val isHovered by interactionSource.collectIsHoveredAsState()
val background = if (isHovered) Color.Red else Color.Blue
Button(
onClick = { },
interactionSource = interactionSource,
colors = ButtonDefaults.buttonColors(
backgroundColor = background
),
) {
Text("Button")
}
}
Louis Pullen-Freilich [G]
07/07/2023, 1:22 PM