Page 1 of 1

wxTreeCtrl item label changing

Posted: Fri Mar 15, 2019 11:19 am
by sackett
Hello everybody!
I'am trying to save new item label after editing:

Code: Select all

void myclass::onTreeEndLabelEdit(wxTreeEvent& event) {
	wxTreeItemId id = event.GetItem();
        wxString str;

	//here I want to store new label but getting the old one.
        str = m_treeCtrl1->GetItemText(id);
}
Please, help.

Re: wxTreeCtrl item label changing

Posted: Fri Mar 15, 2019 11:35 am
by doublemax
You get the new label string through the event object:
https://docs.wxwidgets.org/trunk/classw ... c09d945763

Re: wxTreeCtrl item label changing

Posted: Fri Mar 15, 2019 11:45 am
by sackett
Thank you!
I've read info from your link but no idea how to use it. :(
(How I get the object and how I get a string needed?)

Re: wxTreeCtrl item label changing

Posted: Fri Mar 15, 2019 11:50 am
by doublemax
sackett wrote:
Fri Mar 15, 2019 11:45 am
I've read info from your link but no idea how to use it. :(
(How I get the object and how I get a string needed?)
The wxTreeEvent is passed to the event handler. So all you need is this:

Code: Select all

void myclass::onTreeEndLabelEdit(wxTreeEvent& event) {
  wxTreeItemId id = event.GetItem();
  wxString str = event.GetLabel();

Re: wxTreeCtrl item label changing

Posted: Fri Mar 15, 2019 12:12 pm
by sackett
Now it seems so obvious. Thanks! :)