mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-27 07:44:24 +02:00
Allow Ctrl-TAB to switch tabs in PluginAdmin and UDL dialogs
Fix #7932, close #15015
This commit is contained in:
parent
b7ebd389c7
commit
61083a4468
@ -3711,6 +3711,29 @@ BOOL Notepad_plus::processIncrFindAccel(MSG *msg) const
|
||||
return ::TranslateAccelerator(_incrementFindDlg.getHSelf(), _accelerator.getIncrFindAccTable(), msg);
|
||||
}
|
||||
|
||||
BOOL Notepad_plus::processTabSwitchAccel(MSG* msg) const
|
||||
{
|
||||
HWND hDlg = nullptr;
|
||||
auto isRightDlg = [&msg, &hDlg](HWND hWnd) -> bool {
|
||||
const bool isRight = (hWnd == msg->hwnd || (::IsChild(hWnd, msg->hwnd) == TRUE));
|
||||
if (isRight)
|
||||
{
|
||||
hDlg = hWnd;
|
||||
}
|
||||
return isRight;
|
||||
};
|
||||
|
||||
if (isRightDlg(_findReplaceDlg.getHSelf())
|
||||
|| isRightDlg(_pluginsAdminDlg.getHSelf())
|
||||
|| (ScintillaEditView::getUserDefineDlg() != nullptr
|
||||
&& isRightDlg(ScintillaEditView::getUserDefineDlg()->getHSelf()))
|
||||
)
|
||||
{
|
||||
return static_cast<BOOL>(::TranslateAccelerator(hDlg, _accelerator.getTabSwitchAccTable(), msg));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void Notepad_plus::setLanguage(LangType langType)
|
||||
{
|
||||
//Add logic to prevent changing a language when a document is shared between two views
|
||||
|
@ -501,6 +501,7 @@ private:
|
||||
|
||||
BOOL processIncrFindAccel(MSG *msg) const;
|
||||
BOOL processFindAccel(MSG *msg) const;
|
||||
BOOL processTabSwitchAccel(MSG* msg) const;
|
||||
|
||||
void checkMenuItem(int itemID, bool willBeChecked) const {
|
||||
::CheckMenuItem(_mainMenuHandle, itemID, MF_BYCOMMAND | (willBeChecked?MF_CHECKED:MF_UNCHECKED));
|
||||
|
@ -422,6 +422,9 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
|
||||
|
||||
bool Notepad_plus_Window::isDlgsMsg(MSG *msg) const
|
||||
{
|
||||
if (_notepad_plus_plus_core.processTabSwitchAccel(msg))
|
||||
return true;
|
||||
|
||||
if (_notepad_plus_plus_core.processIncrFindAccel(msg))
|
||||
return true;
|
||||
|
||||
|
@ -1694,25 +1694,9 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
case IDC_NEXT_TAB:
|
||||
case IDC_PREV_TAB:
|
||||
{
|
||||
const int lastTab = TabCtrl_GetItemCount(_tab.getHSelf()) - 1;
|
||||
int selTab = TabCtrl_GetCurSel(_tab.getHSelf());
|
||||
const int selTabIdx = _tab.getNextOrPrevTabIdx(LOWORD(wParam) == IDC_NEXT_TAB);
|
||||
|
||||
if (LOWORD(wParam) == IDC_NEXT_TAB)
|
||||
{
|
||||
if (selTab++ == lastTab)
|
||||
{
|
||||
selTab = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selTab-- == 0)
|
||||
{
|
||||
selTab = lastTab;
|
||||
}
|
||||
}
|
||||
|
||||
switch (static_cast<DIALOG_TYPE>(selTab))
|
||||
switch (static_cast<DIALOG_TYPE>(selTabIdx))
|
||||
{
|
||||
case DIALOG_TYPE::FIND_DLG:
|
||||
{
|
||||
|
@ -1144,7 +1144,7 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_COMMAND :
|
||||
case WM_COMMAND:
|
||||
{
|
||||
if (HIWORD(wParam) == EN_CHANGE)
|
||||
{
|
||||
@ -1153,19 +1153,32 @@ intptr_t CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPA
|
||||
_pUserLang->_ext = ext;
|
||||
return TRUE;
|
||||
}
|
||||
else if (HIWORD(wParam) == CBN_SELCHANGE)
|
||||
else if (HIWORD(wParam) == CBN_SELCHANGE) // HIWORD(wParam) for accelerators is also 1
|
||||
{
|
||||
if (LOWORD(wParam) == IDC_LANGNAME_COMBO)
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_LANGNAME_COMBO:
|
||||
{
|
||||
auto i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETCURSEL, 0, 0);
|
||||
enableLangAndControlsBy(i);
|
||||
updateDlg();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case IDC_NEXT_TAB:
|
||||
case IDC_PREV_TAB:
|
||||
{
|
||||
const int selTabIdx = _ctrlTab.getNextOrPrevTabIdx(LOWORD(wParam) == IDC_NEXT_TAB);
|
||||
_ctrlTab.activateAt(selTabIdx);
|
||||
_ctrlTab.clickedUpdate();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (wParam)
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_DOCK_BUTTON :
|
||||
{
|
||||
|
@ -1187,7 +1187,7 @@ intptr_t CALLBACK PluginsAdminDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
||||
}
|
||||
}
|
||||
|
||||
switch (wParam)
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
if (::GetFocus() == ::GetDlgItem(_hSelf, IDC_PLUGINADM_SEARCH_EDIT))
|
||||
@ -1198,6 +1198,16 @@ intptr_t CALLBACK PluginsAdminDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
||||
display(false);
|
||||
return TRUE;
|
||||
|
||||
case IDC_NEXT_TAB:
|
||||
case IDC_PREV_TAB:
|
||||
{
|
||||
const int selTabIdx = _tab.getNextOrPrevTabIdx(LOWORD(wParam) == IDC_NEXT_TAB);
|
||||
_tab.activateAt(selTabIdx);
|
||||
switchDialog(selTabIdx);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case IDC_PLUGINADM_RESEARCH_NEXT:
|
||||
searchInPlugins(true);
|
||||
return true;
|
||||
|
@ -157,6 +157,28 @@ void TabBar::setFont(const TCHAR *fontName, int fontSize)
|
||||
::SendMessage(_hSelf, WM_SETFONT, reinterpret_cast<WPARAM>(_hFont), 0);
|
||||
}
|
||||
|
||||
int TabBar::getNextOrPrevTabIdx(bool isNext) const
|
||||
{
|
||||
const HWND hTab = _hSelf;
|
||||
const int lastTabIdx = TabCtrl_GetItemCount(hTab) - 1;
|
||||
int selTabIdx = TabCtrl_GetCurSel(hTab);
|
||||
if (isNext)
|
||||
{
|
||||
if (selTabIdx++ == lastTabIdx)
|
||||
{
|
||||
selTabIdx = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selTabIdx-- == 0)
|
||||
{
|
||||
selTabIdx = lastTabIdx;
|
||||
}
|
||||
}
|
||||
return selTabIdx;
|
||||
}
|
||||
|
||||
|
||||
void TabBar::activateAt(int index) const
|
||||
{
|
||||
|
@ -108,6 +108,8 @@ public:
|
||||
return isReduced ? _hFont : _hLargeFont;
|
||||
}
|
||||
|
||||
int getNextOrPrevTabIdx(bool isNext) const;
|
||||
|
||||
protected:
|
||||
size_t _nbItem = 0;
|
||||
bool _hasImgLst = false;
|
||||
|
@ -624,19 +624,33 @@ void Accelerator::updateShortcuts()
|
||||
_hIncFindAccTab = ::CreateAcceleratorTable(tmpIncrFindAccelArray, static_cast<int32_t>(nb));
|
||||
delete [] tmpIncrFindAccelArray;
|
||||
|
||||
if (_hFindAccTab)
|
||||
::DestroyAcceleratorTable(_hFindAccTab);
|
||||
if (_hAccTabSwitch)
|
||||
::DestroyAcceleratorTable(_hAccTabSwitch);
|
||||
|
||||
ACCEL accNextTab{ BYTE{FVIRTKEY | FCONTROL}, VK_TAB, IDC_NEXT_TAB };
|
||||
ACCEL accPrevTab{ BYTE{FVIRTKEY | FCONTROL | FSHIFT}, VK_TAB, IDC_PREV_TAB };
|
||||
findReplaceAcc.emplace_back(accNextTab);
|
||||
findReplaceAcc.emplace_back(accPrevTab);
|
||||
vector<ACCEL> tabSwitchAcc{ accNextTab, accPrevTab };
|
||||
const size_t nbTabSwitchAcc = tabSwitchAcc.size();
|
||||
if (nbTabSwitchAcc > 0)
|
||||
{
|
||||
ACCEL* tmpTabSwitchAcc = new ACCEL[nbTabSwitchAcc];
|
||||
for (i = 0; i < nbTabSwitchAcc; ++i)
|
||||
tmpTabSwitchAcc[i] = tabSwitchAcc.at(i);
|
||||
_hAccTabSwitch = ::CreateAcceleratorTable(tmpTabSwitchAcc, static_cast<int>(nbTabSwitchAcc));
|
||||
delete[] tmpTabSwitchAcc;
|
||||
}
|
||||
|
||||
if (_hFindAccTab)
|
||||
::DestroyAcceleratorTable(_hFindAccTab);
|
||||
|
||||
size_t nbFindReplaceAcc = findReplaceAcc.size();
|
||||
if (nbFindReplaceAcc)
|
||||
{
|
||||
ACCEL* tmpFindAccelArray = new ACCEL[nbFindReplaceAcc];
|
||||
|
||||
for (size_t j = 0; j < nbFindReplaceAcc; ++j)
|
||||
tmpFindAccelArray[j] = findReplaceAcc[j];
|
||||
|
||||
_hFindAccTab = ::CreateAcceleratorTable(tmpFindAccelArray, static_cast<int>(nbFindReplaceAcc));
|
||||
delete[] tmpFindAccelArray;
|
||||
}
|
||||
|
@ -362,6 +362,8 @@ public:
|
||||
::DestroyAcceleratorTable(_hIncFindAccTab);
|
||||
if (_hFindAccTab)
|
||||
::DestroyAcceleratorTable(_hFindAccTab);
|
||||
if (_hAccTabSwitch)
|
||||
::DestroyAcceleratorTable(_hAccTabSwitch);
|
||||
delete [] _pAccelArray;
|
||||
};
|
||||
void init(HMENU hMenu, HWND menuParent) {
|
||||
@ -372,6 +374,7 @@ public:
|
||||
HACCEL getAccTable() const {return _hAccTable;};
|
||||
HACCEL getIncrFindAccTable() const { return _hIncFindAccTab; };
|
||||
HACCEL getFindAccTable() const { return _hFindAccTab; };
|
||||
HACCEL getTabSwitchAccTable() const { return _hAccTabSwitch; };
|
||||
|
||||
void updateShortcuts();
|
||||
void updateFullMenu();
|
||||
@ -382,6 +385,7 @@ private:
|
||||
HACCEL _hAccTable = nullptr;
|
||||
HACCEL _hIncFindAccTab = nullptr;
|
||||
HACCEL _hFindAccTab = nullptr;
|
||||
HACCEL _hAccTabSwitch = nullptr;
|
||||
ACCEL *_pAccelArray = nullptr;
|
||||
int _nbAccelItems = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user