如何区分.Net中的单次点击和双次点击? [英] How can I differentiate between single and double clicks in .Net?

查看:300
本文介绍了如何区分.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.

我确定这必须是一个常见的要求,所以我想我错过了很明显的东西。有人可以填写我吗?

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

Cheers,
Rob

Cheers, Rob

推荐答案

这发生在Windows。我不认为他们添加了任何特殊的处理它在.Net。

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

正常的处理方式是


  • a)只需点击
    ,就可以在双击
    之前点击,例如select。

  • b)如果这不是一个选项,那么在点击事件上,启动一个计时器。在计时器滴答,单击动作。如果双击事件先发生,请删除计时器,然后执行双击操作。

时间应该等于系统的双击时间(用户可以在控制面板中指定)。它可从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天全站免登陆