Say position-only, and stop falsifying the cursor

`is_momentary` becomes `position_only` on both the sense and the cursor,
inverted so it reads as what it tests.

A widget the cursor has left was being handed a blanked cursor so its
press senses would not match. `should_run` now skips non-position senses
when the pointer is not inside, which is the same rule without lying
about the input: the widget still gets the real cursor with its hover
ending.

`consumes` loses its `momentary` argument, since the cursor answers that
itself.
This commit is contained in:
iris committed 2026-09-13 20:43:38 -04:00
1 parent f3fd9417d4
commit e53ce585e6
2 files changed
+39 -42

No files matched your search

+12 -12
View File
@@ -126,8 +126,8 @@ fn full(ui: &mut Ui) -> StrongWidget<Rect> {
#[test]
fn hover_stops_at_the_topmost_widget() {
let mut ui = Ui::new();
let (bottom, middle, top) = (full(&mut ui), full(&mut ui), full(&mut ui));
let ui = &mut Ui::new();
let (bottom, middle, top) = (full(ui), full(ui), full(ui));
let bottom_hover = ui.listen(&bottom, CursorSense::HoverStart);
let middle_hover = ui.listen(&middle, CursorSense::HoverStart);
let top_hover = ui.listen(&top, CursorSense::HoverStart);
@@ -147,8 +147,8 @@ fn hover_stops_at_the_topmost_widget() {
#[test]
fn a_scroll_passes_through_every_widget_that_does_not_want_it() {
let mut ui = Ui::new();
let (list, button, overlay) = (full(&mut ui), full(&mut ui), full(&mut ui));
let ui = &mut Ui::new();
let (list, button, overlay) = (full(ui), full(ui), full(ui));
let scrolled = ui.listen(&list, CursorSense::Scroll);
let clicked = ui.listen(&button, CursorSense::click());
let overlay_clicked = ui.listen(&overlay, CursorSense::click());
@@ -169,8 +169,8 @@ fn a_scroll_passes_through_every_widget_that_does_not_want_it() {
#[test]
fn only_the_topmost_listener_takes_a_press() {
let mut ui = Ui::new();
let (below, above) = (full(&mut ui), full(&mut ui));
let ui = &mut Ui::new();
let (below, above) = (full(ui), full(ui));
let below_clicked = ui.listen(&below, CursorSense::click());
let above_clicked = ui.listen(&above, CursorSense::click());
ui.stack(vec![below.any(), above.any()]);
@@ -185,11 +185,11 @@ fn only_the_topmost_listener_takes_a_press() {
#[test]
fn a_press_beside_the_button_reaches_the_layer_below() {
let mut ui = Ui::new();
let list = full(&mut ui);
let ui = &mut Ui::new();
let list = full(ui);
// The row above the list covers it, but only its left half is the button.
let button = full(&mut ui);
let gap = full(&mut ui);
let button = full(ui);
let gap = full(ui);
let list_clicked = ui.listen(&list, CursorSense::click());
let button_clicked = ui.listen(&button, CursorSense::click());
let row = ui.rsc.ui.widgets.add_strong(Span {
@@ -218,8 +218,8 @@ fn a_press_beside_the_button_reaches_the_layer_below() {
#[test]
fn leaving_a_widget_still_ends_its_hover() {
let mut ui = Ui::new();
let widget = full(&mut ui);
let ui = &mut Ui::new();
let widget = full(ui);
let hover = ui.listen(&widget, CursorSense::HoverStart | CursorSense::HoverEnd);
ui.stack(vec![widget.any()]);