Add a selection change handler for the tree view.

This commit is contained in:
Mark de Wever 2010-02-06 16:18:59 +00:00
parent 0ffeae5447
commit 928436e524
2 changed files with 17 additions and 0 deletions

View file

@ -94,6 +94,11 @@ ttree_view::tnode::tnode(const std::string& id
signal_handler_label_left_button_click
, this, _2, _3, _4)
, event::tdispatcher::front_pre_child);
if(!parent_widget_->selected_item_) {
parent_widget_->selected_item_ = this;
label_->set_value(true);
}
}
return;
@ -380,6 +385,10 @@ void ttree_view::tnode::signal_handler_label_left_button_click(
}
parent_widget_->selected_item_ = this;
if(parent_widget_->selection_change_callback_) {
parent_widget_->selection_change_callback_();
}
}
}
@ -433,6 +442,7 @@ ttree_view::ttree_view(const std::vector<tnode_definition>& node_definitions)
, this
, std::map<std::string, string_map>()))
, selected_item_(NULL)
, selection_change_callback_()
{
}

View file

@ -203,6 +203,11 @@ public:
const tnode* selected_item() const { return selected_item_; }
void set_selection_change_callback(boost::function<void()> callback)
{
selection_change_callback_ = callback;
}
protected:
/***** ***** ***** ***** keyboard functions ***** ***** ***** *****/
@ -235,6 +240,8 @@ private:
tnode* selected_item_;
boost::function<void ()> selection_change_callback_;
/** Inherited from tcontainer_. */
virtual void finalize_setup();