Fix Column Editor OK button not disabled if Text-to-Insert is empty

Fix #13315
This commit is contained in:
Don Ho 2023-04-06 23:43:08 +02:00
parent 6326340ccb
commit 81db72afb3

View File

@ -378,8 +378,8 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
case EN_CHANGE: case EN_CHANGE:
{ {
ColumnEditorParam& colEditParam = NppParameters::getInstance()._columnEditParam; ColumnEditorParam& colEditParam = NppParameters::getInstance()._columnEditParam;
const int stringSize = MAX_PATH; constexpr int stringSize = MAX_PATH;
TCHAR str[stringSize]; TCHAR str[stringSize]{};
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
@ -387,6 +387,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
{ {
::GetDlgItemText(_hSelf, LOWORD(wParam), str, stringSize); ::GetDlgItemText(_hSelf, LOWORD(wParam), str, stringSize);
colEditParam._insertedTextContent = str; colEditParam._insertedTextContent = str;
::EnableWindow(::GetDlgItem(_hSelf, IDOK), str[0]);
return TRUE; return TRUE;
} }
case IDC_COL_INITNUM_EDIT: case IDC_COL_INITNUM_EDIT:
@ -474,6 +475,7 @@ void ColumnEditorDlg::switchTo(bool toText)
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_OCT_RADIO), !toText); ::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_OCT_RADIO), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_BIN_RADIO), !toText); ::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_BIN_RADIO), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_LEADING_COMBO), !toText); ::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_LEADING_COMBO), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDOK), !toText || !NppParameters::getInstance()._columnEditParam._insertedTextContent.empty());
::SetFocus(toText?hText:hNum); ::SetFocus(toText?hText:hNum);