wxTreeCtrl item label changing

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
sackett
In need of some credit
In need of some credit
Posts: 3
Joined: Sun Mar 03, 2019 4:44 am

wxTreeCtrl item label changing

Post by sackett » Fri Mar 15, 2019 11:19 am

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.

User avatar
doublemax
Moderator
Moderator
Posts: 13903
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxTreeCtrl item label changing

Post by doublemax » Fri Mar 15, 2019 11:35 am

You get the new label string through the event object:
https://docs.wxwidgets.org/trunk/classw ... c09d945763
Use the source, Luke!

sackett
In need of some credit
In need of some credit
Posts: 3
Joined: Sun Mar 03, 2019 4:44 am

Re: wxTreeCtrl item label changing

Post by sackett » Fri Mar 15, 2019 11:45 am

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?)

User avatar
doublemax
Moderator
Moderator
Posts: 13903
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxTreeCtrl item label changing

Post by doublemax » Fri Mar 15, 2019 11:50 am

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();
Use the source, Luke!

sackett
In need of some credit
In need of some credit
Posts: 3
Joined: Sun Mar 03, 2019 4:44 am

Re: wxTreeCtrl item label changing

Post by sackett » Fri Mar 15, 2019 12:12 pm

Now it seems so obvious. Thanks! :)

Post Reply