-
Notifications
You must be signed in to change notification settings - Fork 803
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
PointerMoved event sometimes has strange values.
Although the exact reproduction conditions are unclear, they appear to be as follows:
- Another window is present.
- That window has its title color set.
- The mouse cursor is being captured.
Steps to reproduce the bug
- Create new WinUI3 project.
- Add blank window to project.
- Modify code(attached below) and run it.
- Click "Open Window" button.
- Hold down the mouse button and move it slowly on the MainWindow.
- If a strange value is received, "<-- ??" is displayed.
This will not happen if you click on the desktop or other location and then focus on the MainWindow again.
In that case, close the BlankWindow and start over from step 4.
Expected behavior
PointerMoved event will have the correct pointer position.
Screenshots
PointerEvent.mp4
NuGet package version
WinUI 3 - Windows App SDK 1.6.5: 1.6.250205002
Windows version
Windows 11 (24H2): Build 26100
Additional context
MainWindow.xaml
...
<Grid x:Name="myGrid">
<TextBlock x:Name="myTextBlock" />
<Button Click="myButton_Click">Open Window</Button>
</Grid>MainWindow.xaml.cs
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using System;
using Windows.Graphics;
namespace PointerEventTest
{
public sealed partial class MainWindow : Window
{
BlankWindow1? blankWindow = null;
bool pressed;
public MainWindow()
{
this.InitializeComponent();
AppWindow.ResizeClient(new SizeInt32(500, 500));
myGrid.PointerPressed += PointerPressed;
myGrid.PointerMoved += PointerMoved;
myGrid.PointerReleased += PointerReleased;
}
private void PointerPressed(object sender, PointerRoutedEventArgs e) {
((Grid)sender).CapturePointer(e.Pointer);
pressed = true;
}
private void PointerReleased(object sender, PointerRoutedEventArgs e) {
pressed = false;
}
private void PointerMoved(object sender, PointerRoutedEventArgs e) {
var pointer = e.GetCurrentPoint(myGrid);
myTextBlock.Text = String.Format("{0:#.},{1:#.} {2}",
pointer.Position.X,
pointer.Position.Y,
(pressed && !pointer.IsInContact)?"<-- ??":"");
}
private void myButton_Click(object sender, RoutedEventArgs e) {
if (blankWindow == null) {
blankWindow = new BlankWindow1(this.AppWindow);
blankWindow.Closed += (s, args) => {
blankWindow = null;
};
}
blankWindow.Activate();
}
}
}BlankWindow1.xaml.cs
using Microsoft.UI;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using Windows.Graphics;
namespace PointerEventTest
{
public sealed partial class BlankWindow1 : Window
{
public BlankWindow1(AppWindow parent)
{
this.InitializeComponent();
this.AppWindow.TitleBar.ForegroundColor = Colors.Green;
// Resizing is not necessary, but it makes it easier to reproduce.
RectInt32 rect = new RectInt32() { Width = 800, Height = 800,
X = parent.Position.X + 40,
Y = parent.Position.Y + 40 };
this.AppWindow.MoveAndResize(rect);
}
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working