https://kotlinlang.org logo
#compose
Title
# compose
d

Daniele B

04/02/2024, 10:43 AM
I am setting a Text as clickable. However a grey background shows up on mouse over. How to remove such effect?
Copy code
Text(
  modifier = Modifier.clickable { eventFunction() },
  text = "my text",
)
n

Nikolas Guillen Leon

04/02/2024, 10:54 AM
try to use
Copy code
Modifier.clickable(
    enabled = true,
    interactionSource = remember {      MutableInteractionSource() },
    indication = null,
    onClick = eventFunction
)
👍 1
setting "indication" to null should disable the grey background
d

Daniele B

04/02/2024, 11:04 AM
@Nikolas Guillen Leon thanks, it works! I had tried earlier to add
indication = null
, without the
interactionSource
, and it didn't work. I can see it works only if you add the interaction source. Thanks!
👍 1
m

mohamed rejeb

04/02/2024, 11:22 AM
That's because there's two clickable functions and the one with indication has the interactionSource as a required parameter 🫠
thank you color 1
1
d

Daniele B

04/02/2024, 11:25 AM
Thanks @mohamed rejeb for the insight!
3 Views