M6: the mouse wheel scrolls a drop-down's list wherever the pointer is on it

This commit is contained in:
Eric Kaden
2026-10-19 19:37:32 -04:00
parent 5d1303d12e
commit 2169530273
2 changed files with 24 additions and 1 deletions
+1 -1
View File
@@ -769,7 +769,7 @@ fn choice_list(
let p = ui.painter();
p.rect_filled(outer, CornerRadius::ZERO, Color32::WHITE);
// The wheel scrolls the list, a row at a time, and not the page under it.
if area.hovered() && n > shown {
if area.contains_pointer() && n > shown {
st.wheel += ctx.input(|i| i.smooth_scroll_delta.y);
ctx.input_mut(|i| i.smooth_scroll_delta = egui::Vec2::ZERO);
let steps = (st.wheel / row).trunc();
+23
View File
@@ -1222,3 +1222,26 @@ fn a_long_drop_down_list_scrolls_by_its_arrow_button_and_to_its_end() {
h.run_steps(3);
assert_eq!(value(&h, "country"), ["2900"]);
}
#[test]
fn the_mouse_wheel_scrolls_a_long_drop_down_list_and_not_the_page() {
let mut h = harness();
long_country(&mut h);
click_field(&mut h, "country", 0);
let first = egui_kittest::kittest::Queryable::get_by_label(&h, "0000").rect();
let page = h.state().views[0].page_screen_rect(0);
h.hover_at(first.center() + egui::vec2(0.0, first.height() * 4.0));
h.run_steps(1);
for _ in 0..3 {
h.event(egui::Event::MouseWheel {
unit: egui::MouseWheelUnit::Line,
delta: egui::vec2(0.0, -1.0),
modifiers: egui::Modifiers::NONE,
phase: egui::TouchPhase::Move,
});
h.run_steps(2);
}
h.run_steps(6);
assert!(egui_kittest::kittest::Queryable::query_by_label(&h, "0000").is_none(), "the list scrolled down");
assert_eq!(h.state().views[0].page_screen_rect(0), page, "the page stayed where it was");
}