From e94036114b8718480ab35116534125181303b559 Mon Sep 17 00:00:00 2001 From: AngryGamer Date: Sat, 18 Mar 2017 18:59:30 -0700 Subject: [PATCH] Hijack shift+MW hotkey to move tabs rather than switch to them (while drag and drop enabled) --- PowerEditor/src/WinControls/TabBar/TabBar.cpp | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index 8da73f503..eb29cf859 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -476,7 +476,8 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara // will do previous/next tab WITH scroll wrapping (endless loop) // .............................................................................. // SHIFT + MOUSEWHEEL: - // will do previous/next tab WITHOUT scroll wrapping (stops at first/last tab) + // if _doDragNDrop is enabled, then moves the tab, otherwise switches + // to previous/next tab WITHOUT scroll wrapping (stops at first/last tab) // .............................................................................. // CTRL + SHIFT + MOUSEWHEEL: // will switch to the first/last tab @@ -492,6 +493,25 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara { setActiveTab((isForward ? lastTabIndex : 0)); } + else if ((wParam & MK_SHIFT) && _doDragNDrop) + { + int oldTabIndex = static_cast(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0)); + int newTabIndex = oldTabIndex + (isForward ? 1 : -1); + + if (newTabIndex < 0) + { + newTabIndex = lastTabIndex; // wrap scrolling + } + else if (newTabIndex > lastTabIndex) + { + newTabIndex = 0; // wrap scrolling + } + + if (oldTabIndex != newTabIndex) + { + exchangeTabItemData(oldTabIndex, newTabIndex); + } + } else if (wParam & (MK_CONTROL | MK_SHIFT)) { int tabIndex = static_cast(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0) + (isForward ? 1 : -1));