简体   繁体   中英

Clickable areas of image (Mouseover event) - Jetpack Compose Desktop

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM