日期:2014-05-17  浏览次数:21029 次

Label控件鼠标单击事件与双击事件同时存在该怎么办?
Label控件鼠标单击事件与双击事件同时存在,当第一次双击时,只能完成单击事件,不能完成双击事件,只有再次双击时,才能完成双击事件,可是这样的话就没有双击的意义了,它的意义主要是体现快,而单击事件又不能少,请问这该怎么办?

------解决方案--------------------
双击和单击是两回事,不是简单的两个单击
双击都是先触发单击
------解决方案--------------------
可以设置一个标志
BOOL m_tmark; 
要单击事件中 
m_tmark=!m_tmark;


if(FALSE==m_tmark) 
m_time1=GetTickCount(); 
else 
m_time2=GetTickCount(); 

两次单击的时间在250毫秒内就响应相应的消息 
if(m_time1-m_time2 <250||m_time1-m_time2>-250)
------解决方案--------------------
探讨
双击和单击是两回事,不是简单的两个单击
双击都是先触发单击

------解决方案--------------------
IE双击事件同时触发一次单击事件。

非IE,双击事件触发两次单击事件。

以下代码可以区分单击和双击事件。

在Firefox2.0,Firefox3.0,IE6,IE7,Chrome2,Safari3,Opera9.6下测试通过。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>区分单击和双击</title> 
<script type="text/javascript"> 
var flag=0; 
function clickTest() 

if(!flag) 

setTimeout("tt2();",300); 

flag++; 

function reset() 

flag=0; 

function singleClick() 

var result=document.getElementById('result'); 
result.innerHTML=result.innerHTML+"click<br>"; 
reset(); 

function dobuleClick() 

var result=document.getElementById('result'); 
result.innerHTML=result.innerHTML+"dobule click<br>"; 
reset(); 


function tt2() 

if(flag==1) 

singleClick(); 

else 

dobuleClick(); 


</script> 
</head> 
<body> 
<input type="button" ondblclick="clickTest();" onclick="clickTest();" value="click test" /> 
<div id="result"> 
</div> 
</body> 
</html>
来源:http://www.linzhengjian.com/post/2009/08/05/Javascripte58cbae58886e58d95e587bbe5928ce58f8ce587bb.aspx
------解决方案--------------------
探讨
可以设置一个标志
BOOL m_tmark;
要单击事件中
m_tmark=!m_tmark;


if(FALSE==m_tmark)
m_time1=GetTickCount();
else
m_time2=GetTickCount();

两次单击的时间在250毫秒内就响应相应的消息
if(m_time1-m_time2 <250||m_time1-……

------解决方案--------------------

嗯,我测试了一下,双击时都是先触发单击。
不过,我要双及时不触发单及事件不知道如何解决。
我也想知道答案。
private void label1_Click(object sender, EventArgs e)
{
Console.WriteLine("this is click .");
}

private void label1_DoubleClick(object sender, EventArgs e)
{
Console.WriteLine("this is doubleclick .");
}

------解决方案--------------------