你不能讓一個事件需要兩次點擊(當然不包括雙擊事件)。但是,您可以在應用程序中建立一個狀態,第一次點擊開始狀態,第二次點擊完成狀態。僞代碼來管理這個:
// in your constructor:
StartingClickPoint = INVALID; // indicate that we have not entered our special state
// in your mouse event handler:
if (StartingClickPoint == INVALID) {
// we're only now starting this state; we don't have enough information to complete it
StartingClickPoint = CurrentClickPoint;
return;
}
else {
// complete the state handling and arm for the next pair of clicks
EndingClickPoint = CurrentClickPoint;
DoSomethingWithTheClickPoints();
StartingClickPoint = INVALID; // reset for the next pair of clicks
}
來源
2014-04-20 12:51:43
mah
「Moah」你爲什麼刪除你的答案。這是正確的。 – user3328230
假設你對我而言意味着,我在嘗試發佈時遇到了一些網站錯誤。我認爲現在已經解決了,並轉貼了。 – mah