Wpf: WPF can not work well with set IsPressAndHoldEnabled to false when enable pointer message

Created on 26 Aug 2020  路  3Comments  路  Source: dotnet/wpf

  • .NET Core Version: 3.1.301
  • Windows version: (winver)
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes

    Problem description:

We can use Stylus.IsPressAndHoldEnabled="False" to hide the touch feedback when we enable touch feedback in Windows 10.

It can work well when we do not enable the WM_Pointer message.

How to enable touch feedback in Windows 10? See 3 Ways to Enable or Disable Touch Feedback in Windows 10

Actual behavior:

We can find the touch feedback when we enable WM_Pointer message.

Expected behavior:

The behavior of the WPF application is the same as before enable the WM_Pointer message.

We can use Stylus.IsPressAndHoldEnabled="False" to hide the touch feedback. When we hold the screen, the gray rectangle is not displayed.

Minimal repro:

https://github.com/lindexi/lindexi_gd/tree/41884562/KemjawyecawDurbahelal

Most helpful comment

But when I listen to the message and execute the same logic as HwndStylusInputProvider, nothing happens.

This is my demo code: https://github.com/lindexi/lindexi_gd/tree/81b2a63a/KemjawyecawDurbahelal

I think my code is correct, because when I do not enable the WM_Pointer message, this code can work well.

All 3 comments

The WPF will use the HwndPointerInputProvider when we enable the Pointer message. The main code is in System.Windows.Interop.HwndSource.Initialize

            if (StylusLogic.IsStylusAndTouchSupportEnabled)
            {
                // Choose between Wisp and Pointer stacks
                if (StylusLogic.IsPointerStackEnabled)
                {
                    _stylus = new SecurityCriticalDataClass<IStylusInputProvider>(new HwndPointerInputProvider(this));
                }
                else
                {
                    _stylus = new SecurityCriticalDataClass<IStylusInputProvider>(new HwndStylusInputProvider(this));
                }
            }

But the HwndPointerInputProvider ignore the Stylus.IsPressAndHoldEnabledProperty

But when I listen to the message and execute the same logic as HwndStylusInputProvider, nothing happens.

This is my demo code: https://github.com/lindexi/lindexi_gd/tree/81b2a63a/KemjawyecawDurbahelal

I think my code is correct, because when I do not enable the WM_Pointer message, this code can work well.

Was this page helpful?
0 / 5 - 0 ratings