In my case, it would be really just the event of the button itself, I wanted to make an image preview of a pdf page to be somehow "scrollable" by turning the mouse wheel (scroll between the pages, the event would replace the image).
o
olonho
06/23/2021, 3:28 PM
See
Modifier.mouseScrollFilter
then
👀 1
c
Christian Babsek
06/23/2021, 3:29 PM
I will check, thanks already 🙂
Christian Babsek
06/23/2021, 5:59 PM
Thank you very much, it worked perfectly 🙂
Christian Babsek
06/23/2021, 5:59 PM
For anyone who is interested in my solution:
Copy code
@Composable
fun Modifier.onVerticalScroll(
onScrollUp: () -> Unit = {},
onScrollDown: () -> Unit = {}
) = mouseScrollFilter(
onMouseScroll = { event, _ ->
if (event.orientation == MouseScrollOrientation.Vertical) {
when (val delta = event.delta) {
is MouseScrollUnit.Line -> if (delta.value < 0) onScrollUp() else onScrollDown()
is MouseScrollUnit.Page -> if (delta.value < 0) onScrollUp() else onScrollDown()
}
}
false
}
)