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

PointerRoutedEventArgs.GetCurrentPoint() gives a frozen state of the PointerPoint after PointerExited fired #7686

Closed
1 of 2 tasks
WelterDevelopment opened this issue Sep 4, 2022 · 1 comment
Labels
bug Something isn't working no-issue-activity product-winui3 WinUI 3 issues team-CompInput Issue for IXP (Composition, Input) team

Comments

@WelterDevelopment
Copy link

Describe the bug

I am using the PointerExited event of my own text editor control to trigger scrolling (e.g. as in VS, the text scrolls up with a speed depending on the distance of the Pointer to the TextControl). After the scrolling is triggered, a DispatcherTimer should be used to continously get the current state of the Pointer to slow down/ stop the scrolling. But within the DispatcherTimer.Tick event action, calling GetCurrentPoint() only gives the same PointerPoint as in the initial PointerExited event. This worked in WinAppSDK 1.0.X but does not work in 1.1.X anymore. Is this by design? If yes, how can I achieve the wanted behaviour?

Steps to reproduce the bug

  1. Open fresh WinAppSDK 1.1.4 C# App; Add a dummy control to xaml:
<Grid x:Name="TextControl" Background="Red" Height="300" Width="300" PointerExited="Grid_PointerExited"></Grid>
  1. Add the event that starts the DispatcherTimer:
private void Grid_PointerExited(object sender, PointerRoutedEventArgs e)
{
  PointerPoint point = e.GetCurrentPoint(TextControl);
  if (point.Properties.IsLeftButtonPressed)
  {
    if (point.Position.Y < 0)
    {
      DispatcherTimer Timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(1000) };
      Timer.Tick += async (a, b) =>
      {
        PointerPoint pointup = e.GetCurrentPoint(TextControl);
        
        Debug.WriteLine($"Scrolling up with the current Point: {pointup.Position} with LeftButtonPressed state: {pointup.Properties.IsLeftButtonPressed}");
        
        if (pointup.Position.Y > 0 | !pointup.Properties.IsLeftButtonPressed)
        {
          ((DispatcherTimer)a).Stop();
          Debug.WriteLine("Scrolling stopped! But sadly, this code is never reached, since pointup seems to be frozen");
        }
        
        // Do the Scrolling and update the selected text
        // VerticalScroll.Value += pointup.Position.Y;
        // Selection = new(Selection.Start, await PointToPlace(pointup.Position));
      };
      Timer.Start();
    }
  }
}
  1. Run the App, click and hold inside the red Grid, move the cursor upwards to exit the control and to start the DispatcherTimer
  2. Watch the Debug console, move the cursor around, release the left button

Output (even when you move the cursor and release the left button) is always the same:

Scrolling up with the current Point: 172,00003;-0,80000305 with LeftButtonPressed state: True
Scrolling up with the current Point: 172,00003;-0,80000305 with LeftButtonPressed state: True
Scrolling up with the current Point: 172,00003;-0,80000305 with LeftButtonPressed state: True

Expected behavior

pointup.Position should always be the current pointer position and not the 'frozen' pointer position of the PointerExited event. The same problem is with all properties, like pointup.Properties.IsLeftButtonPressed.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.1.4

Windows app type

  • UWP
  • Win32

Device form factor

Desktop

Windows version

Windows 11 (21H2): Build 22000

Additional context

No response

@WelterDevelopment WelterDevelopment added the bug Something isn't working label Sep 4, 2022
@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Sep 4, 2022
@bpulliam bpulliam added the product-winui3 WinUI 3 issues label Oct 12, 2022
@bpulliam bpulliam added the team-CompInput Issue for IXP (Composition, Input) team label Oct 30, 2022
@bpulliam bpulliam removed the needs-triage Issue needs to be triaged by the area owners label Dec 7, 2022
@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working no-issue-activity product-winui3 WinUI 3 issues team-CompInput Issue for IXP (Composition, Input) team
Projects
None yet
Development

No branches or pull requests

2 participants