2

Any idea of how to approach clickable areas on the image? It would be great if in desktop build (yeah the desktop mode is available now :) https://www.jetbrains.com/lp/compose/) they have smth like onMouseover, so they could be highlighted when the mouse is hovering.

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
kocyk
  • 41
  • 1
  • 5

1 Answers1

3

In the Desktop Compose, you can achieve the mouse over actions using the input pointer.

Example:

Image(imageResource("circus.jpg"), Modifier.size(200.dp)
  .pointerMoveFilter(
    onEnter = {
      println("On Mouse(pointer) Enter")
      false
    },
    onExit = {
      println("on Mouse(pointer) Exit")
      false
    }))

Note: pointerMoveFilter is an extension function for Modifier so it's not only for images, we can use it for all components in Desktop Compose.

Ref: Getting Started with Compose for Desktop - Mouse event listeners

malliaridis
  • 389
  • 1
  • 12
Muthukrishnan Rajendran
  • 11,122
  • 3
  • 31
  • 41