make it possible to change the text of the item being edited from OnBeginLabelEdit()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33296 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-04-03 00:27:52 +00:00
parent ed99e548af
commit 646a8a4d0e
2 changed files with 15 additions and 1 deletions

View File

@@ -1105,6 +1105,11 @@ void MyTreeCtrl::OnBeginLabelEdit(wxTreeEvent& event)
event.Veto(); 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) void MyTreeCtrl::OnEndLabelEdit(wxTreeEvent& event)

View File

@@ -2577,6 +2577,10 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
eventType = wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT; eventType = wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT;
TV_DISPINFO *info = (TV_DISPINFO *)lParam; 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_item = info->item.hItem;
event.m_label = info->item.pszText; event.m_label = info->item.pszText;
event.m_editCancelled = false; event.m_editCancelled = false;
@@ -2942,8 +2946,9 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
case TVN_BEGINLABELEDIT: case TVN_BEGINLABELEDIT:
// return true to cancel label editing // return true to cancel label editing
*result = !event.IsAllowed(); *result = !event.IsAllowed();
// set ES_WANTRETURN ( like we do in BeginLabelEdit ) // set ES_WANTRETURN ( like we do in BeginLabelEdit )
if(event.IsAllowed()) if ( event.IsAllowed() )
{ {
HWND hText = TreeView_GetEditControl(GetHwnd()); HWND hText = TreeView_GetEditControl(GetHwnd());
if(hText != NULL) if(hText != NULL)
@@ -2968,6 +2973,10 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
| wxTE_PROCESS_ENTER); | wxTE_PROCESS_ENTER);
} }
} }
else // we had set m_idEdited before
{
m_idEdited.Unset();
}
break; break;
case TVN_ENDLABELEDIT: case TVN_ENDLABELEDIT: