Tim Almdal
03/17/2022, 10:21 PMIconButton/Icon
when the mouse hovers over it. Much like what happens in Winddows, when you move the mouse over the window close button.
I stumble on the MutableInteractSource
but haven't found anything that allows me to et the background. Does anyone have any example I could leverage.
ThanksAlbert Chang
03/18/2022, 12:16 AMLocalIndication
. I think the default indication (indication when you do not apply a material theme) is close to what you want.Tim Almdal
03/18/2022, 12:23 AMLouis Pullen-Freilich [G]
03/18/2022, 12:49 AMval interactionSource = remember { MutableInteractionSource() }
val isHovered by interactionSource.collectIsHoveredAsState()
IconButton(
... interactionSource) {
}
And then use isHovered
to draw a Modifier.background
or similar, depending on your specific use caseLocalContentColor
/ otherwise modify the icon inside in addition to changing background color, to make sure that the constrast is still accessible / to add animations / etcKebbin
03/18/2022, 12:57 AMTim Almdal
03/18/2022, 3:08 AMLouis Pullen-Freilich [G]
03/18/2022, 3:43 PMhoverable
, since clickable
internally also supports hover events by defaultTim Almdal
03/18/2022, 3:55 PMvoyage of discovery
to find these nuances.Louis Pullen-Freilich [G]
03/18/2022, 3:55 PMTim Almdal
03/18/2022, 3:59 PMinteractionSource
parameter had a null default for the indication
parameterChris Sinco [G]
03/18/2022, 5:11 PMLouis Pullen-Freilich [G]
03/18/2022, 5:12 PMclickable
is a higher level thing, that supports press events and combines focusable / hoverable internally - so it’s just a combined modifier that handles press / focus / hover, for higher level components to build on top of