处理按钮手势,单击和点击双击 [英] Handling Button gesture for both single and double click/tap
本文介绍了处理按钮手势,单击和点击双击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Xamarin表单中:我想要能够检测到点击/点击和双击/点击,并能够执行不同的操作。
In Xamarin Forms: I want to be able to detect both click/tap and double-click/tap, and to be able to perform different actions.
是,当点击按钮时,我想执行 actionA
,当按钮被双击时,我想执行 actionB
,而只有 actionB
。
That is, when the button is clicked I want to perform actionA
, and when the button is double-clicked I want to perform actionB
, and only actionB
.
推荐答案
做(对Amit Patil的赞许):
Here's what I ended up doing (kudos to Amit Patil):
private static int clickCount;
private static object _sender;
private void Button_Clicked(object sender, EventArgs e)
{
if (clickCount < 1)
{
TimeSpan tt = new TimeSpan(0, 0, 0, 0, 250);
_sender = sender;
Device.StartTimer(tt, ClickHandle);
}
clickCount++;
}
bool ClickHandle()
{
if (clickCount > 1)
{
Minus1(_sender);
}
else
{
Plus1(_sender);
}
clickCount = 0;
_sender = null;
return false;
}
这篇关于处理按钮手势,单击和点击双击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文