https://kotlinlang.org logo
Title
a

Aaron Yoder

04/17/2021, 8:12 PM
Question about
androidx.compose.ui.input.mouse.MouseScrollEvent
and
MouseScrollUnit
: I am using a
mouseScrollFilter
and am wanting to perform some mathematical operations using the
delta
(for zoom on scroll), but I can't seem to figure out how to get the actual value from the
delta
, there's no accessors or anything for the raw Float value. I understand there's the line/page scroll values but those don't seem accessible either, so not sure if I'm just thinking about this incorrectly.
i

Igor Demin

04/18/2021, 11:09 AM
there's no accessors or anything for the raw Float value
Usually there is no raw Float value (most of the mousses has discrete scroll; except maybe Magic mouse / touchpads)
there's no accessors or anything for the raw Float value
MouseScrollUnit is a sealed class, so you have to check every possible subclass:
val zoomLevel += when (event.delta) {
  is MouseScrollUnit.Line -> value
  is MouseScrollUnit.Page -> value
}

val zoom = zoomLevelToZoomn(zoomLevel)
👌🏻 1
a

Aaron Yoder

04/21/2021, 10:59 AM
That clears up my confusion, thanks!