mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-10-06 07:00:16 +08:00
Allow restarting label editing in wxMSW multi-selection wxTreeCtrl
Unix builds / Ubuntu 24.04 wxGTK ASAN not compatible (push) Canceled after 0s
Unix builds / Ubuntu 26.04 wxGTK UTF-8 (push) Canceled after 0s
Unix builds / Ubuntu 26.04 wxQt (push) Canceled after 0s
Unix builds / Ubuntu 26.04 wxX11 (push) Canceled after 0s
Unix builds / Ubuntu 26.04 wxGTK 2 (push) Canceled after 0s
Unix builds / Ubuntu 20.04 wxGTK 3 with clang (push) Canceled after 0s
Unix builds / Ubuntu 20.04 wxGTK gcc 7 static compatible 3.0 (push) Canceled after 0s
Unix builds / Ubuntu 22.04 wxGTK with wx containers (push) Canceled after 0s
Unix builds / Ubuntu 24.04 wxDFB (push) Canceled after 0s
Unix builds / Ubuntu 24.04 wxGTK UBSAN (push) Canceled after 0s
CMake builds / Ubuntu 22.04 wxGTK 3 (push) Canceled after 0s
CMake builds / macOS latest wxGTK 3 Unix Makefiles (push) Canceled after 0s
CMake builds / MSW/MSVC wxMSW (push) Canceled after 0s
CMake builds / MSW/Clang wxMSW (push) Canceled after 0s
CMake builds / macOS latest wxOSX Ninja (push) Canceled after 0s
CMake builds / macOS 14 wxOSX Xcode (push) Canceled after 0s
CMake builds / macOS 14 wxIOS (push) Canceled after 0s
CMake builds / MSW/MSVC wxQt 5.15 (push) Canceled after 0s
CMake builds / MSW/MSVC wxQt 6.10 (push) Canceled after 0s
Mac builds / wxMac ARM ASAN not compatible (push) Canceled after 0s
Mac builds / wxMac Universal C++14 (push) Canceled after 0s
Mac builds / wxiOS Simulator on Silicon Mac (push) Canceled after 0s
Mac builds / wxiOS (push) Canceled after 0s
Mac builds / wxMac Intel C++17 (push) Canceled after 0s
Mac Xcode builds / iOS Simulator static (push) Canceled after 0s
Mac Xcode builds / macOS dynamic Release (push) Canceled after 0s
Mac Xcode builds / iOS static Debug (push) Canceled after 0s
MSW builds / wxMSW vs2022 DLL Debug x64 (push) Canceled after 0s
MSW builds / wxMSW vs2022 DLL Release x64 (push) Canceled after 0s
MSW builds / wxMSW vs2022 Debug Win32 (push) Canceled after 0s
MSW builds / wxMSW vs2022 Release arm64 (push) Canceled after 0s
MSW builds / wxMSW vs2026 DLL Release x64 (push) Canceled after 0s
MSW cross-builds / wxMSW 64 bits not compatible (push) Canceled after 0s
MSW cross-builds / wxMSW/Univ (push) Canceled after 0s
MSW cross-builds / wxMSW 32 bits (push) Canceled after 0s
Code Checks / Check Spelling (push) Canceled after 0s
Code Checks / Check Whitespace (push) Canceled after 0s
Code Checks / Check Mixed EOL (push) Canceled after 0s
Code Checks / Check C++ Style (push) Canceled after 0s
Code Checks / Check All Headers In allheaders.h (push) Canceled after 0s
Update Documentation / Update Online Documentation (push) Canceled after 0s
Unix builds / Ubuntu 24.04 wxGTK ASAN not compatible (push) Canceled after 0s
Unix builds / Ubuntu 26.04 wxGTK UTF-8 (push) Canceled after 0s
Unix builds / Ubuntu 26.04 wxQt (push) Canceled after 0s
Unix builds / Ubuntu 26.04 wxX11 (push) Canceled after 0s
Unix builds / Ubuntu 26.04 wxGTK 2 (push) Canceled after 0s
Unix builds / Ubuntu 20.04 wxGTK 3 with clang (push) Canceled after 0s
Unix builds / Ubuntu 20.04 wxGTK gcc 7 static compatible 3.0 (push) Canceled after 0s
Unix builds / Ubuntu 22.04 wxGTK with wx containers (push) Canceled after 0s
Unix builds / Ubuntu 24.04 wxDFB (push) Canceled after 0s
Unix builds / Ubuntu 24.04 wxGTK UBSAN (push) Canceled after 0s
CMake builds / Ubuntu 22.04 wxGTK 3 (push) Canceled after 0s
CMake builds / macOS latest wxGTK 3 Unix Makefiles (push) Canceled after 0s
CMake builds / MSW/MSVC wxMSW (push) Canceled after 0s
CMake builds / MSW/Clang wxMSW (push) Canceled after 0s
CMake builds / macOS latest wxOSX Ninja (push) Canceled after 0s
CMake builds / macOS 14 wxOSX Xcode (push) Canceled after 0s
CMake builds / macOS 14 wxIOS (push) Canceled after 0s
CMake builds / MSW/MSVC wxQt 5.15 (push) Canceled after 0s
CMake builds / MSW/MSVC wxQt 6.10 (push) Canceled after 0s
Mac builds / wxMac ARM ASAN not compatible (push) Canceled after 0s
Mac builds / wxMac Universal C++14 (push) Canceled after 0s
Mac builds / wxiOS Simulator on Silicon Mac (push) Canceled after 0s
Mac builds / wxiOS (push) Canceled after 0s
Mac builds / wxMac Intel C++17 (push) Canceled after 0s
Mac Xcode builds / iOS Simulator static (push) Canceled after 0s
Mac Xcode builds / macOS dynamic Release (push) Canceled after 0s
Mac Xcode builds / iOS static Debug (push) Canceled after 0s
MSW builds / wxMSW vs2022 DLL Debug x64 (push) Canceled after 0s
MSW builds / wxMSW vs2022 DLL Release x64 (push) Canceled after 0s
MSW builds / wxMSW vs2022 Debug Win32 (push) Canceled after 0s
MSW builds / wxMSW vs2022 Release arm64 (push) Canceled after 0s
MSW builds / wxMSW vs2026 DLL Release x64 (push) Canceled after 0s
MSW cross-builds / wxMSW 64 bits not compatible (push) Canceled after 0s
MSW cross-builds / wxMSW/Univ (push) Canceled after 0s
MSW cross-builds / wxMSW 32 bits (push) Canceled after 0s
Code Checks / Check Spelling (push) Canceled after 0s
Code Checks / Check Whitespace (push) Canceled after 0s
Code Checks / Check Mixed EOL (push) Canceled after 0s
Code Checks / Check C++ Style (push) Canceled after 0s
Code Checks / Check All Headers In allheaders.h (push) Canceled after 0s
Update Documentation / Update Online Documentation (push) Canceled after 0s
In a tree control with wxTR_MULTIPLE style, a click on the already selected item doesn't start in-place editing if the control had lost focus since the previous click, as such a click is supposed to just restore the focus to the control and nothing else. However the in-place editor itself takes the focus when it is shown, so this flag remained set after the end of any label edit and the next click on the item was silently swallowed instead of starting editing it again, i.e. two clicks were needed to rename the item once more. Don't set the flag when losing focus to our own editor then, but do set it from the EN_KILLFOCUS handler if the editor loses focus to another window, so that clicking back into the control still doesn't start editing. Also check whether the editor is open in the mouse click handler itself, as the click dismissing it shouldn't start a new edit either, which used to be ensured by the same flag. Assisted-by: Claude Opus 5
This commit is contained in:
+27
-3
@@ -2853,6 +2853,14 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
HTREEITEM htOldItem = TreeView_GetSelection(GetHwnd());
|
||||
HTREEITEM htItem = TreeView_HitTest(GetHwnd(), &tvht);
|
||||
|
||||
// If a label is currently being edited, clicking in the tree just
|
||||
// dismisses the editor and shouldn't do anything else, as it happens
|
||||
// in the native control, but we have to check for this here because
|
||||
// calling SetFocus() below ends the editing.
|
||||
bool wasEditing = false;
|
||||
if ( nMsg == WM_LBUTTONDOWN )
|
||||
wasEditing = TreeView_GetEditControl(GetHwnd()) != nullptr;
|
||||
|
||||
switch ( nMsg )
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
@@ -3034,8 +3042,9 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
m_htClickedItem.Unset();
|
||||
|
||||
// prevent in-place editing from starting if focus lost
|
||||
// since previous click
|
||||
if ( m_focusLost )
|
||||
// since previous click or if this click just dismissed
|
||||
// the editor used for editing another label
|
||||
if ( m_focusLost || wasEditing )
|
||||
{
|
||||
ClearFocusedItem();
|
||||
DoSelectItem(wxTreeItemId(htItem));
|
||||
@@ -3278,7 +3287,16 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
|
||||
if ( nMsg == WM_KILLFOCUS )
|
||||
{
|
||||
m_focusLost = true;
|
||||
// Losing the focus to our own in-place editor doesn't really
|
||||
// count as losing it: if we did consider it lost here, the click
|
||||
// on the selected item after the end of the label editing
|
||||
// wouldn't start editing it again, as it should, because we would
|
||||
// have taken it for a click just restoring the focus to the
|
||||
// control (if the editor loses the focus to another window later,
|
||||
// we do set the flag from the EN_KILLFOCUS handler below).
|
||||
const HWND hwndEdit = TreeView_GetEditControl(GetHwnd());
|
||||
if ( !hwndEdit || (HWND)wParam != hwndEdit )
|
||||
m_focusLost = true;
|
||||
}
|
||||
}
|
||||
else if ( (nMsg == WM_KEYDOWN || nMsg == WM_SYSKEYDOWN) && isMultiple )
|
||||
@@ -3328,6 +3346,12 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
{
|
||||
if ( m_textCtrl && m_textCtrl->GetHandle() == hwnd )
|
||||
{
|
||||
// We don't set m_focusLost when giving the focus to the
|
||||
// editor (see WM_KILLFOCUS handling above), so do it now if
|
||||
// the focus goes to some other window and not back to us.
|
||||
if ( ::GetFocus() != GetHwnd() )
|
||||
m_focusLost = true;
|
||||
|
||||
DoEndEditLabel();
|
||||
|
||||
processed = true;
|
||||
|
||||
Reference in New Issue
Block a user