Double Click vs Single Click - are these mutually

2019-02-17 08:19发布

Can anyone name an instance of an application where clicking an entity (say image) does one thing, but if you double-click it it does something different?

The only example I've been able to find is in double-clicking a track in iTunes but then that selects it (single click function) and then plays it (double-click function) which implies (logically) that double click is the superset (containing single-click).

Basically, I am being asked to implement (in WPF) an image single-click doing one thing and an image double-click doing another thing and I'm not sure if this is even conceptually correct.

If someone has an example of anyone sensibly doing this that would be appreciated?

8条回答
The star\"
2楼-- · 2019-02-17 08:54
private void OnItemMouseDown(object sender, MouseButtonEventArgs e) {
    if(e.ClickCount==2) {
        // DoubleClick Function
    }

    if(e.ClickCount==1) {
        // Click Function
    }
}
查看更多
迷人小祖宗
3楼-- · 2019-02-17 08:57

Microsoft Excel. Move your mouse over an unselected cell.

Single click = cell selection

Double click = enter edit mode for that cell

查看更多
我想做一个坏孩纸
4楼-- · 2019-02-17 09:01

The most obvious would seem to be Finder/Explorer, where single-clicking a file selects it and double-clicking opens it. There's plenty of precedent for this sort of thing, and people are well trained by its inclusion in the OS level to expect double click to do different things.

  • Text selection (in just about every app in existence) - single click to place the cursor, double click to select the word, triple click to select the whole line.
  • Explorer / Finder - single click to select a file, double click to open it.
  • Outlook - single click to preview an e-mail, double click to open in a new window.
查看更多
Root(大扎)
5楼-- · 2019-02-17 09:02

It's generally a bad pattern to make a double click do something unrelated to the single click behavior. In order to distinguish between the single click and the double click, you have to wait for a moment to see if the second click arrives. That can cause a disconcerting delay when you're just single-clicking something.

Raymond Chen has a good blog post on this issue, including how to do it.

But I'd push back on the designer first.

查看更多
劳资没心,怎么记你
6楼-- · 2019-02-17 09:03

From a Windows messaging perspective, a double-click always generates a single click message first; Windows can't predict ahead of time that another click will come in time to turn it into a double-click. I can't imagine that WPF is going to hide this physical fact from you.

查看更多
forever°为你锁心
7楼-- · 2019-02-17 09:13

In answer to the direct question: Double Click vs Single Click - are these mutually exclusive? The answer is no, these are not mutually exclusive due to the manner in which Windows needs to interpret your behaviour with the mouse.

However, in answer to the more vague question regarding a precedent where a double click does not include the behaviour of single click [i.e. The two events exhibit mutually exclusive behaviour], there are some specific events in Windows that appear to exhibit the behaviour you're asking about.

For instance - the taskbar applets:

  • Single click usually opens a shortcut menu for that item.
  • Double click usually opens the properties menu for the application which that task bar item is linked to without opening the shortcut menu.

The taskbar clock:

  • Single click does nothing.
  • Double click opens the Date and Time properties.

You may notice however that it takes a moment to respond to your request and as others have noted that pause is Windows waiting to see if you're going to double click. If you don't double click then the Click behaviour is fired. If you do double click then the DoubleClick behaviour is fired. In these specific situations it was deemed suitable to have mutually exclusive behaviour and there may be some others.

I think it really depends on the situation as to whether the different behaviour is "right" or "wrong" - I don't think you can equivocably say that one is right and the other wrong in all situations. If the behaviour you are looking to exhibit makes good logical sense from a user perspective [not from your own programmer perspective], then sure, make the behaviour mutually exclusive; if however it doesn't make good logical sense to the user then avoid it.

查看更多
登录 后发表回答