]> git.saurik.com Git - wxWidgets.git/commitdiff
end label editing if the control loses focus (slightly modified patch 1084592)
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 20 Dec 2004 01:23:52 +0000 (01:23 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 20 Dec 2004 01:23:52 +0000 (01:23 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31084 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/treectrl.h
src/msw/treectrl.cpp

index 9667717cefe26e78be360ab1b046e19e0fac87d5..019467ec624ab936b1338e95e598199a41b5090f 100644 (file)
@@ -340,7 +340,11 @@ public:
         // edited simultaneously)
     wxTextCtrl* GetEditControl() const;
         // end editing and accept or discard the changes to item label
-    void EndEditLabel(const wxTreeItemId& item, bool discardChanges = false);
+    void EndEditLabel(const wxTreeItemId& WXUNUSED(item),
+                      bool discardChanges = false)
+    {
+        DoEndEditLabel(discardChanges);
+    }
 
     // sorting
         // this function is called to compare 2 items and should return -1, 0
@@ -446,6 +450,10 @@ protected:
     // refresh a single item
     void RefreshItem(const wxTreeItemId& item);
 
+    // end edit label
+    void DoEndEditLabel(bool discardChanges = false);
+
+
     // data used only while editing the item label:
     wxTextCtrl  *m_textCtrl;        // text control in which it is edited
     wxTreeItemId m_idEdited;        // the item being edited
index b7329c5289178ace09ea60d6e6d3b0dc8790acda..ac8c5f927a90eedc9e0bba8c4f638e4eecf48f98 100644 (file)
@@ -2053,7 +2053,7 @@ wxTextCtrl* wxTreeCtrl::EditLabel(const wxTreeItemId& item,
 }
 
 // End label editing, optionally cancelling the edit
-void wxTreeCtrl::EndEditLabel(const wxTreeItemId& WXUNUSED(item), bool discardChanges)
+void wxTreeCtrl::DoEndEditLabel(bool discardChanges)
 {
     TreeView_EndEditLabelNow(GetHwnd(), discardChanges);
 
@@ -2476,6 +2476,24 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara
             processed = true;
         }
     }
+    else if ( nMsg == WM_COMMAND )
+    {
+        // if we receive a EN_KILLFOCUS command from the in-place edit control
+        // used for label editing, make sure to end editing
+        WORD id, cmd;
+        WXHWND hwnd;
+        UnpackCommand(wParam, lParam, &id, &hwnd, &cmd);
+
+        if ( cmd == EN_KILLFOCUS )
+        {
+            if ( m_textCtrl && m_textCtrl->GetHandle() == hwnd )
+            {
+                DoEndEditLabel();
+
+                processed = true;
+            }
+        }
+    }
 
     if ( !processed )
         rc = wxControl::MSWWindowProc(nMsg, wParam, lParam);