WinRT-XAML 中的 Click、Tapped 和 PointerPressed 是同义词吗? [英] Are Click, Tapped, and PointerPressed synonymous in WinRT-XAML?

查看:23
本文介绍了WinRT-XAML 中的 Click、Tapped 和 PointerPressed 是同义词吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否为 PointerPressed、Click 或 Tapped 创建事件处理程序是否重要?IOW,以下之间是否有任何功能差异:

Does it matter whether I create event handlers for PointerPressed, Click, or Tapped?IOW, is there any functional difference between the following:

<Button x:Name="BackButton" PointerPressed="BackButton_Click"/>    
<Button x:Name="BackButton" Click="BackButton_Click"/>    
<Button x:Name="BackButton" Tapped="BackButton_Click"/>

?

推荐答案

Click 是为了向后兼容,本质上与 Tapped 相同.Tapped 是一种高级手势",它会自动转换为点击、点击、笔压等,这是我推荐使用的.

Click is there for backwards compatibility, and is essentially the same as Tapped. Tapped is a "high level gesture" that will translate automatically to a click, tap, pen press, etc. and is what I would recommend to use.

PointerPressed 不是你想要的.原因如下:如果我按住,PointerPressed 事件将在我最初按下"时触发,然后 PointerReleased 将在完成后触发.这是更低级别的,您可以决定按下多长时间等.通常,长按不是您想要考虑的点击"或点击",因为根据定义,点击的持续时间较短.因此,对于您想要的,Tap"最能传达它,因为它使用系统计时为您翻译手势,用于被认为是Tap"与按住的内容,并自动将点击和笔按下提升到同一事件.无论交互持续多长时间,只要按下按钮或按下手指,PointerPressed 就会触发.

PointerPressed is not what you want. Here's why: if I press and hold, the PointerPressed event will fire when I initially "press" and then a PointerReleased will fire once it's done. This is more low-level and you can make decisions about how long it was pressed, etc. Typically a long press is NOT what you want to consider a "Click" or a "Tap" because by definition Tap is shorter duration. Therefore, for what you want, "Tap" conveys it best because it translates the gesture for you using the system timing for what is considered a "Tap" vs. a hold and automatically promotes clicks and pen presses to the same event. PointerPressed will fire whenever a button is pressed or a finger is pressed regardless of how long the interaction lasts.

我有一个相当复杂的应用程序,它演示了您可以从 http://windows8applications.codeplex.com - 只需参考第 4 章名为触摸"的示例.

I have a fairly involved app that demonstrates the various interactions that you can download from http://windows8applications.codeplex.com - just refer to the Chapter 4 sample called "Touch."

这篇关于WinRT-XAML 中的 Click、Tapped 和 PointerPressed 是同义词吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆