]> git.saurik.com Git - wxWidgets.git/commitdiff
made SetItemText() work for the item which we're about to start editing
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 17 May 2002 23:54:42 +0000 (23:54 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 17 May 2002 23:54:42 +0000 (23:54 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15599 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/treectrl.cpp

index 84a8b01c20f42fdd61073a7b9593f7a5e9a14044..9a393feba7d3ab46f10d37da121083c1daba6cf9 100644 (file)
@@ -891,6 +891,20 @@ void wxTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text)
     wxTreeViewItem tvItem(item, TVIF_TEXT);
     tvItem.pszText = (wxChar *)text.c_str();  // conversion is ok
     DoSetItem(&tvItem);
+
+    // when setting the text of the item being edited, the text control should
+    // be updated to reflect the new text as well, otherwise calling
+    // SetItemText() in the OnBeginLabelEdit() handler doesn't have any effect
+    //
+    // don't use GetEditControl() here because m_textCtrl is not set yet
+    HWND hwndEdit = TreeView_GetEditControl(GetHwnd());
+    if ( hwndEdit )
+    {
+        if ( item == GetSelection() )
+        {
+            ::SetWindowText(hwndEdit, text);
+        }
+    }
 }
 
 int wxTreeCtrl::DoGetItemImageFromData(const wxTreeItemId& item,
@@ -1761,7 +1775,7 @@ void wxTreeCtrl::ScrollTo(const wxTreeItemId& item)
     }
 }
 
-wxTextCtrlwxTreeCtrl::GetEditControl() const
+wxTextCtrl *wxTreeCtrl::GetEditControl() const
 {
     return m_textCtrl;
 }