Fixed issue #2507: Support keyboard shortcuts in yes/no prompts
[TortoiseGit.git] / src / Utils / MiscUI / TripleClick.h
blobf6bc000db7230275bd8fb351d6498f4df8997a6f
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2011-2012 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
22 /**
23 * \ingroup Utils
24 * Helper to catch tripple mouse clicks.
26 class CTripleClick
28 public:
29 CTripleClick()
30 : m_LastDblClickMsg(0)
31 , m_LastDblClickTime(0)
34 virtual ~CTripleClick() {}
36 virtual void OnLButtonTrippleClick(UINT /*nFlags*/, CPoint /*point*/) {}
37 virtual void OnMButtonTrippleClick(UINT /*nFlags*/, CPoint /*point*/) {}
38 virtual void OnRButtonTrippleClick(UINT /*nFlags*/, CPoint /*point*/) {}
40 BOOL RelayTrippleClick(MSG* pMsg)
42 if ( (pMsg->message == WM_LBUTTONDBLCLK) ||
43 (pMsg->message == WM_MBUTTONDBLCLK) ||
44 (pMsg->message == WM_RBUTTONDBLCLK))
46 m_LastDblClickMsg = pMsg->message;
47 m_LastDblClickTime = GetTickCount();
49 else if (
50 ((pMsg->message == WM_LBUTTONDOWN)&&(m_LastDblClickMsg == WM_LBUTTONDBLCLK)) ||
51 ((pMsg->message == WM_MBUTTONDOWN)&&(m_LastDblClickMsg == WM_MBUTTONDBLCLK)) ||
52 ((pMsg->message == WM_RBUTTONDOWN)&&(m_LastDblClickMsg == WM_RBUTTONDBLCLK))
55 if ((GetTickCount() - GetDoubleClickTime()) < m_LastDblClickTime)
57 m_LastDblClickTime = 0;
58 m_LastDblClickMsg = 0;
59 CPoint pt;
60 pt.x = GET_X_LPARAM(pMsg->lParam);
61 pt.y = GET_Y_LPARAM(pMsg->lParam);
62 switch (pMsg->message)
64 case WM_LBUTTONDOWN:
65 OnLButtonTrippleClick((UINT)pMsg->wParam, pt);
66 break;
67 case WM_MBUTTONDOWN:
68 OnMButtonTrippleClick((UINT)pMsg->wParam, pt);
69 break;
70 case WM_RBUTTONDOWN:
71 OnRButtonTrippleClick((UINT)pMsg->wParam, pt);
72 break;
74 return TRUE;
77 return FALSE;
79 private:
80 UINT m_LastDblClickMsg;
81 DWORD m_LastDblClickTime;