-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Improve pen secondary button handling on list box #18766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…nt(null)` behaves the same as root visual
This reverts commit 2562d73.
You can test this PR using the following package version. |
Will test this once my pen arrives (should be next week) |
@@ -64,9 +64,11 @@ protected override void OnPointerPressed(PointerPressedEventArgs e) | |||
if (p.Properties.PointerUpdateKind is PointerUpdateKind.LeftButtonPressed or | |||
PointerUpdateKind.RightButtonPressed) | |||
{ | |||
if (p.Pointer.Type == PointerType.Mouse) | |||
if (p.Pointer.Type == PointerType.Mouse | |||
|| (p.Pointer.Type == PointerType.Pen && p.Properties.IsRightButtonPressed)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to update the logic in PointerReleased handler here (line 108):
// As we only update selection from touch/pen on pointer release, we need to raise
// the pointer event on the owner to trigger a commit.
if (e.Pointer.Type != PointerType.Mouse)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not going to get there, since _pointerDownPoint is unset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, seems to work consistently with the rest of windows apps with my pen
* Only start ScrollGesture when left click pressed, also `GetCurrentPoint(null)` behaves the same as root visual * Allow right-click pen to select items on press * Add context menus to even items on ListBox page for testing * Avoid global static in UpdateSelectionFromPointerEvent * Revert "Avoid global static in UpdateSelectionFromPointerEvent" This reverts commit 2562d73. * Add comment to UpdateSelectionFromPointerEvent * Use fully mocked rendering for list box test * Add pen selection tests * TouchTestHelper should use correct inputs
What does the pull request do?
Historically, pen input in Avalonia copies touch input behavior way too much. It makes sense in some areas, like primary button press to scroll. But not so much with secondary/right button press. Touch doesn't have a secondary button at all, but pen should copy mouse behavior there.
Some operations are hard to achieve with pen, now are possible/easier with this PR: dnd with pen (at least in-process), selecting item AND showing context menu on same press+release combo.
This PR makes following changes:
This PR behavior is closer to WPF than UWP though, as UWP doesn't select list item if there is a context menu. But majority of modern windows apps follow WPF logic from my observation (including this PR).
What is the current behavior?
What is the updated/expected behavior with this PR?
* DND related rules are not part of this PR, and not part of Avalonia itself. User applications and third-party controls decide themselves when to call
DragDrop.Do
(by filtering pointer props usually in PointerPressed event). I added these columns for the completion.Pending: TreeDataGrid changes for the same rules.
Checklist
Breaking changes
Pen right click has different behavior now.
Obsoletions / Deprecations
Fixed issues
Fixes https://support.avaloniaui.net/agent/tickets/444