Hey guys, I wrote a .scrollable(zoomScrollState, O...
# compose-desktop
a
Hey guys, I wrote a .scrollable(zoomScrollState, Orientation.Vertical) modifier, but I need the mouse position in order to zoom around where the mouse is. How can I get mouse position in scrollable modifier?
k
MouseInfo.getPointerInfo().getLocation()
You might need to use
SwingUtilities.convertPointFromScreen
to convert that to the coord system of your component
a
@Kirill Grouchnikov Thank you! The
convertPointFromScreen
has a component parameter, how can I retrieve the component from a compose element in my function?
Maybe I should just use
onPointerEvent(PointEventType.Scroll)
as that seems a more desktop oriented API (I can get a reference to the awt mouse event)
k
Probably the
OnGloballyPositionedModifier
would be better suited for the conversion then.
a
I need to know the mouse position at the time the user does scroll though, so how would that work with onGloballyPositioned?
k
That one is for translating the mouse location from screen to your composable