Pin the hover-then-scroll case, and say what the line means
A wheel makes `position_only` false, so a button already hovered in a layer above does not consume it -- but the line read as though it might. `hovering_a_button_above_does_not_stop_a_later_scroll` is that case in the two frames a window actually delivers it in, and the comment now leads with it. `resting` is renamed to `position_only`, so the same word is used throughout.
This commit is contained in:
1 parent
827d317f41
commit
8cac927438
2 files changed
+32
-7
No files matched your search
@@ -263,3 +263,28 @@ fn leaving_a_widget_does_not_block_the_layer_below() {
|
||||
"ending a hover above must not stop the hover below"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hovering_a_button_above_does_not_stop_a_later_scroll() {
|
||||
let ui = &mut Ui::new();
|
||||
let (list, button) = (full(ui), full(ui));
|
||||
let scrolled = ui.listen(&list, CursorSense::Scroll);
|
||||
let clicked = ui.listen(&button, CursorSense::click());
|
||||
ui.stack(vec![list.any(), button.any()]);
|
||||
|
||||
// The hover arrives in its own frame, as a window delivers it.
|
||||
let hover = ui.cursor((50.0, 50.0));
|
||||
ui.run(hover);
|
||||
assert_eq!(scrolled.take(), []);
|
||||
|
||||
let mut wheel = ui.cursor((50.0, 50.0));
|
||||
wheel.scroll_delta = (0.0, 10.0).into();
|
||||
ui.run(wheel);
|
||||
|
||||
assert_eq!(
|
||||
scrolled.take(),
|
||||
[CursorSense::Scroll],
|
||||
"a hover already resting on the button must not consume the wheel"
|
||||
);
|
||||
assert_eq!(clicked.take(), []);
|
||||
}
|
||||
Reference in new issue
Block a user