Skip to content
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

ScrollViewer children are silently losing pointer events after PointerExited with pen & touch #9290

Open
abrown313 opened this issue Jan 26, 2024 · 2 comments
Labels
area-Scrolling bug Something isn't working team-Controls Issue for the Controls team

Comments

@abrown313
Copy link

Describe the bug

I'm implementing an item selection experience inside a ScrollViewer and have noticed some quirks with capturing the pointer and working around the ScrollViewer manipulation processing with pen & touch.

First, my child item needs PointerPresed, PointerMoved, and PointerReleased/PointerCaptureLost at a minimum. To get this working with mouse, I capture the pointer in the PointerPressed event and that ensures I still get Move & Released/Lost events outside the bounds of the child. With pen & touch, I had the additional requirement to listen for DirectManipulationStarted on the ScrollViewer parent and when that happens during a selection session, I call CancelDirectManipulations on the parent. This works great! Except, if the pointer leaves the child during the selection session, it gets the Exited event and then nothing else until the pointer returns inside its bounds. It's unclear exactly where the pointer capture is going because CaptureLost or CaptureCanceled aren't fired and neither is the DirectManipulationStarted. I can work around this issue be explicitly re-capturing the pointer in the PointerExited if I need to, but it's odd that this is necessary.

I've also found that this isn't a problem when the ScrollViewer doesn't have enough content to actually scroll, but as soon as it does this problem repros.

Steps to reproduce the bug

  1. Create a WinUI 3 C++/WinRT project (WASDK Version 1.3.230602002 if that helps)
  2. To the MainWindow, add a ScrollViewer containing a StackPanel, which in turn contains a Canvas and some filler Rectangles to ensure the ScrollViewer has enough to scroll through.
  3. On the Canvas, register for all the relevant pointer events. Define a selection "session" with an enum or bool that starts OnPressed and ends OnReleased/OnCaptureLost. Also in the Pressed handling, call CapturePointer(args.Pointer()).
  4. On the ScrollViewer, register for DirectManipulationStarted. Define a handler to invoke CancelDirectManipulations if a selection session is active.
  5. With pen or touch, press in the bounds of the Canvas and drag outside the bounds.

Expected behavior

Expected: Since the pointer is captured, you'd keep getting pointer events after OnExited.
Actual: You stop getting pointer events after OnExited until the pointer re-enters the bounds.

Screenshots

No response

NuGet package version

None

Windows version

No response

Additional context

There's also another problem where Tapped events with pen/touch also fire a single Moved between the Pressed & Released, but that's not a problem here.

@abrown313 abrown313 added the bug Something isn't working label Jan 26, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jan 26, 2024
@codendone codendone added area-Scrolling team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Feb 15, 2024
@ranjeshj
Copy link
Contributor

ranjeshj commented Mar 5, 2024

@abrown313 can you briefly explain the scenario/experience you are trying to achieve?

@ranjeshj ranjeshj added the needs-author-feedback Asked author to supply more information. label Mar 5, 2024
@abrown313
Copy link
Author

@ranjeshj It's a custom selection experience within a ScrollViewer, so clicking & dragging to select objects like selecting text in a text editor. Within the selection control, we're capturing pointer input to ensure a user can drag outside of the container and the selection will be continued. For example, if you're selecting text in Notepad, you can drag outside the bounds of the app and the text selection continues to update. We want that same behavior for our selection control, but the bounds of the ScrollViewer are creating an unexpected limitation as described in the bug.

@microsoft-github-policy-service microsoft-github-policy-service bot added needs-triage Issue needs to be triaged by the area owners and removed needs-author-feedback Asked author to supply more information. labels Mar 6, 2024
@codendone codendone removed the needs-triage Issue needs to be triaged by the area owners label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Scrolling bug Something isn't working team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

3 participants