Code: Select all
const String TreeItem::EventTreeItemExpanded( "TreeItemExpanded" );
I wired the click of the button to a new method (I'm using a toggle button created by me):
Code: Select all
button->subscribeEvent(ToggleButton::EventCheckStateChanged, Event::Subscriber(&CEGUI::TreeItem::button_SelectionHandler, this));
and in button_SelectionHandler I fire an event:
Code: Select all
bool TreeItem::button_SelectionHandler(const EventArgs& e)
{
this->setExpanded(!this->isExpanded());
WindowEventArgs args(this);
onExpandedChanged(args);
return true;
}
and onExpandedChanged code:
Code: Select all
void TreeItem::onExpandedChanged(WindowEventArgs& e)
{
fireEvent(EventTreeItemExpanded, e, EventNamespace);
}
In my application I subscribe the list with this event:
Code: Select all
WindowManager::getSingleton().getWindow("Demo7/Window2/Listbox")->
subscribeEvent(TreeItem::EventTreeItemExpanded, Event::Subscriber(&Demo7Sample::handleExpand, this));
But when I click the button all these methods are executed but the one in my application. Because the use I'll have with these trees is very dynamic I wouldn't like to subscribe each node of the tree. How can I make this event to be subscribed by the list and make it work?
Thanks,
José Tavares