点击,点击和指针在WinRT-XAML中同义吗? [英] Are Click, Tapped, and PointerPressed synonymous in WinRT-XAML?

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

问题描述

是否为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" Margin="0,3,0,0" Style="{StaticResource BackButtonStyle}" PointerPressed="BackButton_Click"/>

<Button x:Name="BackButton" Margin="0,3,0,0" Style="{StaticResource BackButtonStyle}" Click="BackButton_Click"/>

<Button x:Name="BackButton" Margin="0,3,0,0" Style="{StaticResource BackButtonStyle}" Tapped="BackButton_Click"/>

推荐答案

点击是为了向后兼容,并且与点相同。轻拍是一种高级手势,将自动转换为点击,点按,笔按等,这是我建议使用的。

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不是你想要的。这就是为什么:如果我按住,当我最初按时,指针压力的事件将触发,然后一个指针释放将会一旦完成就会触发。这是更低级别,您可以决定按下多长时间等。通常,长按不是您想要考虑的点击或点击,因为定义点击更短的持续时间。因此,为了达到您想要的目的,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 下载 - 只需参考第四章Touch的示例。

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中同义吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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