]> git.saurik.com Git - wxWidgets.git/commitdiff
make it possible to change the text of the item being edited from OnBeginLabelEdit()
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 3 Apr 2005 00:27:52 +0000 (00:27 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 3 Apr 2005 00:27:52 +0000 (00:27 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33296 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/treectrl/treetest.cpp
src/msw/treectrl.cpp

index 3a3f8d43e1f1f7cdd62e87fdf774e3acae4ce922..5ff0f681ff165ed979e656c4d9a922c08b82835a 100644 (file)
@@ -1105,6 +1105,11 @@ void MyTreeCtrl::OnBeginLabelEdit(wxTreeEvent& event)
 
         event.Veto();
     }
+    else if ( itemId == GetRootItem() )
+    {
+        // test that it is possible to change the text of the item being edited
+        SetItemText(itemId, _T("Editing root item"));
+    }
 }
 
 void MyTreeCtrl::OnEndLabelEdit(wxTreeEvent& event)
index 4e277888cf91abe7e7d6b2d7b9672e9f9083270f..8cc634935eedc1d129c7556adf02e9fa53dffff1 100644 (file)
@@ -2577,6 +2577,10 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                 eventType = wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT;
                 TV_DISPINFO *info = (TV_DISPINFO *)lParam;
 
+                // although the user event handler may still veto it, it is
+                // important to set it now so that calls to SetItemText() from
+                // the event handler would change the text controls contents
+                m_idEdited =
                 event.m_item = info->item.hItem;
                 event.m_label = info->item.pszText;
                 event.m_editCancelled = false;
@@ -2942,8 +2946,9 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
         case TVN_BEGINLABELEDIT:
             // return true to cancel label editing
             *result = !event.IsAllowed();
+
             // set ES_WANTRETURN ( like we do in BeginLabelEdit )
-            if(event.IsAllowed())
+            if ( event.IsAllowed() )
             {
                 HWND hText = TreeView_GetEditControl(GetHwnd());
                 if(hText != NULL)
@@ -2968,6 +2973,10 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                                                | wxTE_PROCESS_ENTER);
                 }
             }
+            else // we had set m_idEdited before
+            {
+                m_idEdited.Unset();
+            }
             break;
 
         case TVN_ENDLABELEDIT: