1

single-click vs double-click dilemma

I have an event happening for a single-click, and I have a different event happening for double-click.

Single-click: load preview of email message

Double-click: load message view in different window

The issue is that in order for a double-click to occurr, a single-click happens... twice. The current solution has been to put a timeout on the single-click and cancel it if the double-click is detected.

Question 1: What is the timeout on a double-click event to occur? If I single-click really slowly, it won't take place, for example.

Question 2: Is there a better way to solve this than to use a timeout?

4

4 回答 4

3

您绝对应该重新考虑您的 UI。看看你身边的应用程序,尤其是在 Windows 中:当支持双击时,单击动作总是被触发,并且不显眼。例如,当双击一个图标时,第一次单击将选择它,第二次单击将触发动作。至少有两个原因:

  1. 双击是一个复杂的操作。用户有时会失败,而是触发单击操作。因此,你不想做任何可能惹恼他的事情。

  2. 如果您不想在每次用户双击时触发单击操作,那么除了设置超时之外别无他法。这意味着每个尝试使用单击的用户都必须忍受该超时,从而降低应用程序的响应能力并阻碍用户体验。

我可以添加一个特定于 WP7 开发的原因:由于大多数其他移动应用程序中没有使用双击,因此手势不可发现,并且大多数用户不会意识到他们可以使用它。

底线:考虑使用其他手势(如扫动或点击并按住),或更改您的 UI 以使其不必要。

于 2012-05-18T09:24:43.650 回答
1

我在朋友的帮助下找到了答案。

private void Button_Tap(object sender, GestureEventArgs e)
    {
        //add the event handler for single tap event
        dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
        //start timer. If the tick happends a single tap happend. If it is a double tap the tick event will be removed.
        dispatcherTimer.Start();
    }

    //No double tap happend. So execute the tap function.
    private void dispatcherTimer_Tick(object sender, EventArgs e)
    {
        //Stop timer
        dispatcherTimer.Tick -= new EventHandler(dispatcherTimer_Tick);
        dispatcherTimer.Stop();

        //Rest of the tap function
        Taps.Add("Tap");
    }

    private void Button_DoubleTap(object sender, GestureEventArgs e)
    {
        //Stop timer
        dispatcherTimer.Tick -= new EventHandler(dispatcherTimer_Tick);
        dispatcherTimer.Stop();

        //Rest of the double tap function
        Taps.Add("Double tap");
    }
于 2012-05-18T17:20:58.600 回答
0

你为什么不使用别的东西。点击以在新窗口中打开按住预览?

于 2012-05-18T09:22:53.010 回答
0

on wp7, doubleTap is likely never used. Hold would be the right way to go

于 2012-05-18T19:00:23.897 回答