直接用窗體的click和doubleclick事件相應函式是沒辦法區分的,因為click在doubleclick前面被觸發。
辦法一:
在mousedown事件中處理,通過timer計算兩次單擊時間差。
private bool isfirstclick = true;
private bool isdoubleclick = false;
private int milliseconds = 0;
private rectangle hittestrectangle = new rectangle();
private rectangle doubleclickrectangle = new rectangle();
// detect a valid single click or double click.
private void form1_mousedown(object sender, mouseeventargs e)
// this is the first mouse click.
if (isfirstclick)
// this is the second mouse click.
else
}}
timer相應函式:
private void timer1_tick(object sender, eventargs e) //計算間隔時間
else
// allow the mousedown event handler to process clicks again.
isfirstclick = true;
isdoubleclick = false;
milliseconds = 0;
}}
參考:
Cesium 滑鼠單擊和雙擊事件
cesium 滑鼠雙擊事件實際上是 先執行了兩次單擊再進行雙擊,因而如果給繫結的左鍵單擊事件,則可能會獲取不到雙擊事件,下面使用定時器功能區分單雙擊事件 let handler new cesium.screenspaceeventhandler viewer.canvas let timer nu...
iOS touch事件區分單擊雙擊響應的方法
如果您的 iphone 應用裡有個 view,既有單擊操作又有雙擊操作。使用者雙擊 view 時,總是先執行一遍單擊的操作再執行雙擊的操作。所以直接判斷時就會發現不能直接進入雙擊操作。下面是區分 touch 事件是單擊還是雙擊的方法 void singletap void doubletap voi...
labview區分單擊和雙擊
在labview中經常會遇到需要按鍵雙擊的時候,並且labview本身也確實提供了雙擊的事件。如下圖所示 但是這樣有乙個問題,檢測按鈕按下時,這個事件本身就先執行了一次,快速按下第二次時,會判斷出是雙擊事件,但是前面第一次按鍵已經執行了一次了,並且前面的按鍵事件不是雙擊事件。這個功能在只需要雙擊事件...