fix(iced): handle scroll events

This commit is contained in:
Hojjat 2026-03-13 18:10:51 -06:00 • committed by Ashley Wulber
parent 9b0ebf30bb
commit 7491547d70

View file

@ -463,24 +463,37 @@ impl SctkEvent {
time: _, time: _,
horizontal, horizontal,
vertical, vertical,
source, source: _,
} => { } => {
if let Some(e) = let delta = if horizontal.value120 != 0
pointer_axis_to_native(source, horizontal, vertical) || vertical.value120 != 0
.map(|a| {
iced_runtime::core::Event::Mouse(
mouse::Event::WheelScrolled { delta: a },
)
})
{ {
events.push(( mouse::ScrollDelta::Lines {
surface_ids x: -horizontal.value120 as f32 / 120.,
.get(&variant.surface.id()) y: -vertical.value120 as f32 / 120.,
.map(|id| id.inner()), }
e, } else if horizontal.discrete != 0
)); || vertical.discrete != 0
} {
} // TODO Ashley: conversion mouse::ScrollDelta::Lines {
x: -horizontal.discrete as f32,
y: -vertical.discrete as f32,
}
} else {
mouse::ScrollDelta::Pixels {
x: -horizontal.absolute as f32,
y: -vertical.absolute as f32,
}
};
events.push((
surface_ids
.get(&variant.surface.id())
.map(|id| id.inner()),
iced_runtime::core::Event::Mouse(
mouse::Event::WheelScrolled { delta },
),
));
}
}, },
SctkEvent::KeyboardEvent { SctkEvent::KeyboardEvent {
variant, variant,