Fix double clicking on border creates a new tab issue

Fix https://github.com/notepad-plus-plus/notepad-plus-plus/pull/16561#issuecomment-2938756492
Close #16755
This commit is contained in:
Anthony Lee Stark 2025-06-26 14:51:24 +07:00 committed by Don Ho
parent 884f8cdc06
commit 105a141a43
3 changed files with 31 additions and 8 deletions

View File

@ -3013,7 +3013,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case WM_LBUTTONDBLCLK:
{
::SendMessage(hwnd, WM_COMMAND, IDM_FILE_NEW, 0);
DocTabView* curTabView = (currentView() == MAIN_VIEW) ? &_mainDocTab : &_subDocTab;
::SendMessage(curTabView->getHSelf(), WM_LBUTTONDBLCLK, wParam, lParam);
return TRUE;
}

View File

@ -316,7 +316,7 @@ LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam)
: (pt.y < 0 ? _pWin0 : _pWin1);
::SendMessage(parent, NPPM_INTERNAL_SWITCHVIEWFROMHWND, 0, reinterpret_cast<LPARAM>(targetWindow->getHSelf()));
::SendMessage(parent, WM_COMMAND, IDM_FILE_NEW, 0);
::SendMessage(parent, WM_LBUTTONDBLCLK, wParam, lParam);
return TRUE;
}

View File

@ -1175,14 +1175,35 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
case WM_LBUTTONDBLCLK:
{
bool isDbClk2Close = NppParameters::getInstance().getNppGUI()._tabStatus & TAB_DBCLK2CLOSE;
if (isDbClk2Close)
NppParameters& nppParam = NppParameters::getInstance();
NppGUI& nppGUI = nppParam.getNppGUI();
bool isVertical = nppGUI._tabStatus & TAB_VERTICAL;
bool isDbClk2Close = nppGUI._tabStatus & TAB_DBCLK2CLOSE;
int xPos = LOWORD(lParam);
int yPos = HIWORD(lParam);
int currentTabOn = getTabIndexAt(xPos, yPos);
if (currentTabOn != -1)
{
int xPos = LOWORD(lParam);
int yPos = HIWORD(lParam);
int currentTabOn = getTabIndexAt(xPos, yPos);
notify(TCN_TABDELETE, currentTabOn);
if (isDbClk2Close)
notify(TCN_TABDELETE, currentTabOn);
}
else
{
POINT pt{};
GetCursorPos(&pt);
RECT rcLastTab{};
TabCtrl_GetItemRect(_hSelf, static_cast<int32_t>(TabCtrl_GetItemCount(_hSelf)) - 1, &rcLastTab);
ClientRectToScreenRect(_hSelf, &rcLastTab);
bool isDbClickOnTabStrip = isVertical ? (pt.x < rcLastTab.right) : (pt.y < rcLastTab.bottom);
if (isDbClickOnTabStrip)
::SendMessage(_hParent, WM_COMMAND, IDM_FILE_NEW, 0);
}
return TRUE;
}