Open aquinn39 opened 2 years ago
The Initialize method in System.Windows.Interop.HwndSource
will check the StylusLogic.IsPointerStackEnabled
as the code:
if (StylusLogic.IsStylusAndTouchSupportEnabled)
{
// Choose between Wisp and Pointer stacks
if (StylusLogic.IsPointerStackEnabled)
{
// Enable the pointer support.
_stylus = new SecurityCriticalDataClass<IStylusInputProvider>(new HwndPointerInputProvider(this));
}
else
{
_stylus = new SecurityCriticalDataClass<IStylusInputProvider>(new HwndStylusInputProvider(this));
}
}
Before enable the pointer support, it will enter the logic of HwndStylusInputProvider. And the HwndStylusInputProvider will return the flags when receive the WM_TABLET_QUERYSYSTEMGESTURESTATUS message in Hook.
private IntPtr Hook(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam, ref bool handled)
{
const int WM_TABLET_DEFBASE =0x02C0;
const int WM_TABLET_QUERYSYSTEMGESTURESTATUS = WM_TABLET_DEFBASE + 12;
const int WM_TABLET_FLICK = WM_TABLET_DEFBASE + 11;
if (msg == WM_TABLET_QUERYSYSTEMGESTURESTATUS)
{
uint flags = 0;
flags |= TABLET_PRESSANDHOLD_DISABLED;
flags |= TABLET_TAPFEEDBACK_DISABLED;
flags |= TABLET_TOUCHUI_FORCEON;
flags |= TABLET_TOUCHUI_FORCEOFF;
flags |= TABLET_FLICKS_DISABLED;
handled = true;
return new IntPtr(flags);
}
else if (msg == WM_TABLET_FLICK)
{
handled = true;
return new IntPtr(1);
}
return IntPtr.Zero;
}
private const uint TABLET_PRESSANDHOLD_DISABLED = 0x00000001;
private const uint TABLET_TAPFEEDBACK_DISABLED = 0x00000008;
private const uint TABLET_TOUCHUI_FORCEON = 0x00000100;
private const uint TABLET_TOUCHUI_FORCEOFF = 0x00000200;
private const uint TABLET_FLICKS_DISABLED = 0x00010000;
But it will do nothing, although we add the hook manually, when we enable the pointer support.
Hello! Are there any news on this?
We are facing the same problem: we cannot figure out how to disable the right click press-and-hold behavior when we have Switch.System.Windows.Input.Stylus.EnablePointerSupport
enabled.
Thanks a lot in advance for any help!
@bastio84 Seems like the Windows limitation
@bastio84 I find the soluction, see https://github.com/dotnet/wpf/issues/3379#issuecomment-1819092721
Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? No
Problem description:
Actual behavior: Tapping and holding on a control with Stylus.IsPressAndHoldEnabled disabled while the app has Switch.System.Windows.Input.Stylus.EnablePointerSupport enabled simply results in the same behaviour as if Stylus.IsPressAndHoldEnabled was enabled (pressing and holding results in a right click rather than a normal click, also if the control is something like a button, its state does not indicate that it is currently in the pressed state). Basically, Stylus.IsPressAndHoldEnabled has no effect when Switch.System.Windows.Input.Stylus.EnablePointerSupport is on.
Expected behavior: Stylus.IsPressAndHoldEnabled being set to false on a control should have the same effect as it does when Switch.System.Windows.Input.Stylus.EnablePointerSupport is disabled.
Minimal repro: Create a new WPF app, call AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.EnablePointerSupport", "True") in the application startup event. Then, set Stylus.IsPressAndHoldEnabled to disabled on any control, such as a button (e.g. Stylus.SetIsPressAndHoldEnabled(Button1, False)). Stylus.IsPressAndHoldEnabled will have no effect on the control.