Double Click vs Single Click - are these mutually exclusive

寵の児 提交于 2019-12-01 01:57:43

问题


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?


回答1:


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.




回答2:


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.




回答3:


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.



回答4:


In Cooliris, if you click a cell in the wall, it gets selected. If you double click the image, it transitions to a full screen slide show mode, starting at that image.




回答5:


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:


Microsoft Excel. Move your mouse over an unselected cell.

Single click = cell selection

Double click = enter edit mode for that cell




回答7:


Wrapping up what's said by others here, double click does not "cancel" a single click.

As a consequence to that, you should never do something in a double-click event that depends on a state that is changed by a single click - because a single click is always executed first!

The other way around, you can rely on that the state after a single click is valid when starting the double click action. Example: Single click in a file list selects the file, so in the double click event you know that the clicked file is selected...




回答8:


private void OnItemMouseDown(object sender, MouseButtonEventArgs e) {
    if(e.ClickCount==2) {
        // DoubleClick Function
    }

    if(e.ClickCount==1) {
        // Click Function
    }
}


来源:https://stackoverflow.com/questions/970898/double-click-vs-single-click-are-these-mutually-exclusive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!