diff --git a/src/gui/widgets/combobox.cpp b/src/gui/widgets/combobox.cpp index 02d1616506b4..f684cb52787e 100644 --- a/src/gui/widgets/combobox.cpp +++ b/src/gui/widgets/combobox.cpp @@ -144,6 +144,9 @@ void tcombobox::signal_handler_left_button_click(const event::tevent event, if(droplist.show(get_window()->video())) { selected_ = droplist.selected_item(); this->set_label(values_[selected_]); + if(selected_callback_) { + selected_callback_(*this); + } if(retval_ != 0) { twindow* window = get_window(); if(window) { diff --git a/src/gui/widgets/combobox.hpp b/src/gui/widgets/combobox.hpp index ef2d7863ae3f..5dad1ae803f8 100644 --- a/src/gui/widgets/combobox.hpp +++ b/src/gui/widgets/combobox.hpp @@ -72,6 +72,13 @@ class tcombobox : public tcontrol, public tclickable_, public tselectable_ /** Inherited from tselectable_ */ virtual unsigned num_states() const OVERRIDE { return values_.size(); } + + /** Inherited from tselectable_ */ + virtual void set_callback_state_change(boost::function callback) + { + selected_callback_ = callback; + } + private: /** * Possible states of the widget. @@ -108,6 +115,9 @@ class tcombobox : public tcontrol, public tclickable_, public tselectable_ /** */ int selected_; + + boost::function selected_callback_; + /** See @ref tcontrol::get_control_type. */ virtual const std::string& get_control_type() const OVERRIDE;