Skip to content

Conversation

@PoignardAzur
Copy link
Contributor

Keeping this as a draft, because I think we already want non-primary clicks on buttons to send actions. This very low-priority for now.

@PoignardAzur PoignardAzur marked this pull request as draft August 13, 2025 19:22
@waywardmonkeys
Copy link
Contributor

Curious what the reasoning is behind this and whether anyone else does this?

@DJMcNab
Copy link
Member

DJMcNab commented Aug 14, 2025

The right click behaviour matches e.g. Firefox (but obviously, that also open a context menu, which we don't have).

As accidentally demonstrated when I did right-click, escape, enter on the "ready for review" button!

@DJMcNab DJMcNab marked this pull request as ready for review August 14, 2025 08:36
@DJMcNab DJMcNab marked this pull request as draft August 14, 2025 08:36
@PoignardAzur
Copy link
Contributor Author

It's also the behavior for middle-click, and I assume other non-primary clicks? I haven't tested it in that much detail.

@PoignardAzur
Copy link
Contributor Author

On closer inspection, I realized that the web behavior is "Any click on an focusable widget focuses it". It's just that primary clicks on buttons and links will usually navigate away, so we don't notice them.

@PoignardAzur PoignardAzur marked this pull request as ready for review September 19, 2025 16:09
@PoignardAzur PoignardAzur changed the title DRAFT: Make non-primary click events focus buttons and checkboxes. Make non-primary click events focus buttons and checkboxes. Sep 19, 2025
Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change currently has a fatal flaw for touch screens, and

The small hack of supporting | None is something which I'd be willing for us to land. But I would like to double check who needed this support originally first.

Comment on lines +116 to +121
if *button == Some(PointerButton::Primary) {
ctx.capture_pointer();
// Changes in pointer capture impact appearance, but not accessibility node
ctx.request_paint_only();
trace!("Button {:?} pressed", ctx.widget_id());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change means that buttons are no longer usable on touch screens (e.g. on Android).
We cannot land this change with that regression in place.

It also breaks button_any_pointer on the Xilem side, which is fine, but we should just remove it if we're doing that. But no longer supporting touch screens is not a good plan. button_any_pointer was added as a quick hack to unblock a user, but I'm not going to dig into who that was at the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what kind of filter could we use that accepts touchscreen presses but rejects right-clicks?

Is it Some(PointerButton::Primary) | None ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I should have said that explicitly

Comment on lines +376 to +387
#[test]
fn button_right_click() {
let button = NewWidget::new(Button::with_text("Hello"));

let mut harness = TestHarness::create(default_property_set(), button);
let button_id = harness.root_id();

harness.mouse_move_to(button_id);
harness.mouse_button_press(PointerButton::Secondary);
assert_eq!(harness.focused_widget_id(), Some(button_id));
assert_matches!(harness.pop_action_erased(), None);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a test for an emulated touch event here. That's a Down event with a button of None.

trace!("Button {:?} pressed", ctx.widget_id());
}
// Any click event should lead to this widget getting focused.
ctx.request_focus();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this set the focus anchor, rather than actually setting the focus directly? I think either way would be viable. On the web, it seems to do the former, from some brief testing.

This doesn't block this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants