From d51fc12841d14d5471d0e094ee73c65faf7828e5 Mon Sep 17 00:00:00 2001 From: JamesAC Date: Wed, 31 Aug 2011 14:49:45 +0000 Subject: [PATCH] Holding Ctrl while clicking ignores LeftMouseDown and RightMouseUp actions, so the defaults, dragging and accessing context menu, are done instead. --- Library/MeterWindow.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 3fdf9117..337f545b 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -4307,6 +4307,18 @@ LRESULT CMeterWindow::OnLeftButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam) // Handle buttons HandleButtons(pos, BUTTONPROC_DOWN, NULL); + SHORT state = GetKeyState(VK_CONTROL); + bool down = ((unsigned short) state) >> 15; + // Ctrl is pressed, so only run default action + if (down) + { + // Cancel the mouse event beforehand + SetMouseLeaveEvent(true); + + // Run the DefWindowProc so the dragging works + return DefWindowProc(m_Window, uMsg, wParam, lParam); + } + if (!DoAction(pos.x, pos.y, MOUSE_LMB_DOWN, false) && m_WindowDraggable) { // Cancel the mouse event beforehand @@ -4415,6 +4427,14 @@ LRESULT CMeterWindow::OnRightButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam) // Handle buttons HandleButtons(pos, BUTTONPROC_MOVE, NULL); + SHORT state = GetKeyState(VK_CONTROL); + bool down = ((unsigned short) state) >> 15; + // Ctrl is pressed, so only run default action + if (down) + { + return DefWindowProc(m_Window, WM_RBUTTONUP, wParam, lParam); + } + if (!DoAction(pos.x, pos.y, MOUSE_RMB_UP, false)) { // Run the DefWindowProc so the context menu works @@ -4563,10 +4583,16 @@ LRESULT CMeterWindow::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam) // Handle buttons HandleButtons(posc, BUTTONPROC_MOVE, NULL); - // If RMB up or RMB down or double-click cause actions, do not show the menu! - if (DoAction(posc.x, posc.y, MOUSE_RMB_UP, false) || DoAction(posc.x, posc.y, MOUSE_RMB_DOWN, true) || DoAction(posc.x, posc.y, MOUSE_RMB_DBLCLK, true)) + SHORT state = GetKeyState(VK_CONTROL); + bool down = ((unsigned short) state) >> 15; + // Ctrl is pressed, so ignore any actions + if (!down) { - return 0; + // If RMB up or RMB down or double-click cause actions, do not show the menu! + if (DoAction(posc.x, posc.y, MOUSE_RMB_UP, false) || DoAction(posc.x, posc.y, MOUSE_RMB_DOWN, true) || DoAction(posc.x, posc.y, MOUSE_RMB_DBLCLK, true)) + { + return 0; + } } }