我如何区分单,双点击的.NET之间? [英] How can I differentiate between single and double clicks in .Net?

查看:183
本文介绍了我如何区分单,双点击的.NET之间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要重写OnMouseClick和OnMouseDoubleClick和执行,这取决于点击风格采用不同的操作。

I want to override OnMouseClick and OnMouseDoubleClick and perform different actions depending on which click style was used.

问题是,OnMouseClick正在发生的单,双点击和OnMouseDoubleClick之前获取调用。

The problem is that OnMouseClick is happening for both single and double clicks, and is getting called before OnMouseDoubleClick.

我敢肯定,这必须是一个常见的​​需求,所以我想我失去了一些东西pretty的明显。可有人填补我?

I'm certain this must be a common requirement, so I guess I'm missing something pretty obvious. Can someone fill me in?

编辑补充:在MouseEventArgs.Clicks计数不帮助。在一个双​​击的情况下,第一次点击是作为一个单一的点击在OnMouseClick与MouseEventArgs.Clicks == 1处理。

Edit to add: the MouseEventArgs.Clicks count doesn't help. In the case of a double-click, the first click is handled as a single click in OnMouseClick with MouseEventArgs.Clicks == 1.

编辑补充:对象是图片的缩略图。只需点击一下,应该选择切换和关闭出口。双击应使缩略图全屏。选择和激活行动是正交的。这可能表明一个潜在的问题,这两个动作...

Edit to add: the objects are image thumbnails. Single click should toggle selection on and off for export. Double click should make the thumbnail full screen. The selection and "activation" actions are orthogonal. This may indicate an underlying problem with the two actions...

干杯, 罗布

推荐答案

这是发生在整个Windows操作系统。我不认为他们增加了什么特别的处理它在.NET。

That happens throughout Windows. I don't think they added anything special to handle it in .Net.

处理这个正常的手段就是

The normal means of handling this is

  • A)只是做单一的点击事 你想之前的双重发生 单击,就像选择。
  • 二)如果这不是一个选项,然后在单击事件,启动一个定时器。计时器滴答,做一次点击的动作。如果先发生的双击事件,终止计时器,并执行双击操作。
  • a) just make single click something you'd want to happen before a double click, like select.
  • b) if that's not an option, then on the click event, start a timer. On the timer tick, do the single click action. If the double-click event occurs first, kill the timer, and do the double click action.

你设置的时间的时间量应等于系统的双击时间(用户可以在控制面板中指定)。这可从System.Windows.Forms.SystemInformation.DoubleClickTime。完整的细节是在MSDN,这里

The amount of time you set the time for should be equal to the system's Double-Click time (which the user can specify in the control panel). It's available from System.Windows.Forms.SystemInformation.DoubleClickTime. The full details are in the MSDN, here

这篇关于我如何区分单,双点击的.NET之间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆