双击与单击 - 它们是互斥的吗

发布于 2024-07-23 07:48:08 字数 241 浏览 4 评论 0原文

任何人都可以命名一个应用程序的实例,其中单击实体(例如图像)会执行一件事,但如果双击它则会执行不同的操作?

我能找到的唯一例子是双击 iTunes 中的曲目,然后选择它(单击功能),然后播放它(双击功能),这意味着(逻辑上)双击是超集(包含单击)。

基本上,我被要求实现(在 WPF 中)图像单击执行一件事,图像双击执行另一件事,我不确定这在概念上是否正确。

如果有人有一个明智地这样做的例子,我将不胜感激?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

烟若柳尘 2024-07-30 07:48:08

从 Windows 消息传递的角度来看,双击总是首先生成单击消息; Windows 无法提前预测是否会及时发生另一次单击,从而将其转变为双击。 我无法想象 WPF 会向您隐藏这个物理事实。

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.

最后的乘客 2024-07-30 07:48:08

回答直接问题:双击与单击 - 它们是相互排斥的吗? 答案是否定的,由于 Windows 需要解释您的鼠标行为的方式,这些并不相互排斥。

然而,为了回答关于双击不包括单击行为的先例的更模糊的问题[即两个事件表现出相互排斥的行为],Windows 中的一些特定事件似乎表现出您的行为正在询问。

例如 - 任务栏小程序:

  • 单击通常会打开该项目的快捷菜单。
  • 双击通常会打开该任务栏项目链接到的应用程序的属性菜单,而无需打开快捷菜单。

任务栏时钟:

  • 单击不执行任何操作。
  • 双击打开日期和时间属性。

然而,您可能会注意到,需要一些时间来响应您的请求,并且正如其他人所指出的那样,暂停是 Windows 等待查看您是否要双击。 如果您不双击,则会触发单击行为。 如果双击,则会触发 DoubleClick 行为。 在这些特定情况下,被认为适合采取相互排斥的行为,并且可能还有其他一些行为。

我认为这实际上取决于具体情况,不同的行为是“对”还是“错” - 我认为你不能在所有情况下模棱两可地说一个是对的,另一个是错的。 如果您希望展示的行为从用户的角度来看(而不是从您自己的程序员的角度)具有良好的逻辑意义,那么当然,使该行为互斥; 然而,如果它对用户来说没有很好的逻辑意义,那么就避免它。

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.

东北女汉子 2024-07-30 07:48:08

让双击执行与单击行为无关的操作通常是一个不好的模式。 为了区分单击和双击,你必须等待片刻,看看第二次点击是否到来。 当您只是单击某些内容时,这可能会导致令人不安的延迟。

Raymond Chen 在这个问题上发表了一篇很好的博客文章 ,包括如何做。

但我首先会反驳设计师。

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.

羁绊已千年 2024-07-30 07:48:08

最明显的是 Finder/Explorer,单击文件即可将其选中,双击即可将其打开。 此类事情有很多先例,并且人们通过将其包含在操作系统级别中而受到良好的训练,期望双击可以执行不同的操作。

  • 文本选择(几乎在现有的每个应用程序中) - 单击以放置光标,双击以选择单词,三次单击以选择整行。
  • 资源管理器/查找器 - 单击选择文件,双击打开它。
  • Outlook - 单击可预览电子邮件,双击可在新窗口中打开。

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.
我偏爱纯白色 2024-07-30 07:48:08

Cooliris 中,如果您单击墙上的一个单元格,它就会被选中。 如果双击图像,它将转换为全屏幻灯片放映模式,从该图像开始。

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.

空城仅有旧梦在 2024-07-30 07:48:08

微软Excel。 将鼠标移到未选定的单元格上。

单击=选择单元格

双击=进入该单元格的编辑模式

Microsoft Excel. Move your mouse over an unselected cell.

Single click = cell selection

Double click = enter edit mode for that cell

老子叫无熙 2024-07-30 07:48:08

总结一下其他人在这里所说的,双击不会“取消”单击。

因此,您永远不应该在双击事件中执行依赖于单击更改的状态的操作 - 因为单击始终首先执行!

相反,在启动双击操作时,您可以相信单击后的状态是有效的。 示例:在文件列表中单击即可选择该文件,因此在双击事件中您知道所单击的文件已被选择...

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...

望她远 2024-07-30 07:48:08
private void OnItemMouseDown(object sender, MouseButtonEventArgs e) {
    if(e.ClickCount==2) {
        // DoubleClick Function
    }

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

    if(e.ClickCount==1) {
        // Click Function
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文