在 WPF 应用程序中禁用右键单击(按住)。

发布于 2024-11-06 13:38:49 字数 169 浏览 0 评论 0原文

我正在开发在 Windows XP Standard 上运行的触摸屏应用程序。使用当前的硬件来调用右键单击,用户必须单击并按住几秒钟,但这可能会干扰其他操作,例如在滚动查看器中按住重复按钮,因此我决定禁用右键单击。

理想情况下,我不想禁用应用程序级别的右键单击,但如果不可能,禁用窗口级别的右键单击也适合我。

I am working on the touch screen application which is running on Windows XP Standard. With current hardware to invoke a right click user has to click and hold for couple of seconds, but this might interfere with other actions like holding a repeat button in the scrollviewer, so I have decide to disable a right click.

I would ideally wan't to disable a right click on the application level, but if it is not possible, disable right click on windows level would also work for me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦醒灬来后我 2024-11-13 13:38:49

OnPreviewMouseRightButtonDown/Up 方法对我不起作用。

  1. UIElement 上有一个属性 Stylus.IsPressAndHoldEnabled然而。将其设置为 false 以消除按住右键单击行为。我在带有 .NET 4.0 的 Windows 7 上对此进行了测试,但该属性可从 .NET 3.0 获得。

  2. 还有一篇博文此处提供了在窗口级别类似地禁用按住的代码示例。但有了这个,一旦手指触摸屏幕,PreviewTouchDown 和 TouchDown 事件就不会被引发(我猜这对于 RepeatButton 来说是必要的),只有稍后才会引发。请阅读此 msdn 页面上的“备注”。

The OnPreviewMouseRightButtonDown/Up approach did not work for me.

  1. There is a property Stylus.IsPressAndHoldEnabled on UIElement however. Set that to false to get rid of the press and hold right click behavior. I tested this on Windows 7 with .NET 4.0, but the property is available from .NET 3.0.

    <RepeatButton Stylus.IsPressAndHoldEnabled="false" ... />

  2. There is also a blogpost here that provides a code sample for a similar disabling of press and hold at window level. But with this in place, the PreviewTouchDown and TouchDown events will not be raised as soon as the finger touches the screen (which would be necessary for a RepeatButton I guess), only later. Read the 'Remarks' on this msdn page.

小清晰的声音 2024-11-13 13:38:49

您可以覆盖窗口上的 OnPreviewMouseRightButtonDown 并将 Handled 设置为 true。您还需要处理 OnPreviewMouseRightButtonUp (感谢 Vitalij 指出这一点)

这应该可以解决问题。

You can override the OnPreviewMouseRightButtonDown on the Window and set Handled to true. You also need to handle OnPreviewMouseRightButtonUp (thanks to Vitalij for pointing this out)

That should do the trick.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文