Reimplement the value changed callback.
It seems the callback got lost in the rewrite. Added a hacky version will need more testing later.
This commit is contained in:
parent
b4b264ea1a
commit
fb6ea9965e
2 changed files with 21 additions and 2 deletions
|
@ -34,6 +34,7 @@ tlistbox::tlistbox(const bool has_minimum, const bool has_maximum,
|
|||
: tscrollbar_container(2) // FIXME magic number
|
||||
, generator_(NULL)
|
||||
, list_builder_(NULL)
|
||||
, callback_value_changed_(NULL)
|
||||
{
|
||||
generator_ = tgenerator_::build(
|
||||
has_minimum, has_maximum, placement, select);
|
||||
|
@ -139,6 +140,9 @@ void tlistbox::list_item_clicked(twidget* caller)
|
|||
|
||||
if(generator_->get_item(i).has_widget(caller)) {
|
||||
generator_->toggle_item(i);
|
||||
if(callback_value_changed_) {
|
||||
callback_value_changed_(this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -174,6 +178,9 @@ void tlistbox::handle_key_up_arrow(SDLMod modifier, bool& handled)
|
|||
|
||||
show_content_rect(rect);
|
||||
|
||||
if(callback_value_changed_) {
|
||||
callback_value_changed_(this);
|
||||
}
|
||||
} else {
|
||||
// Inherited.
|
||||
tscrollbar_container::handle_key_up_arrow(modifier, handled);
|
||||
|
@ -198,6 +205,9 @@ void tlistbox::handle_key_down_arrow(SDLMod modifier, bool& handled)
|
|||
|
||||
show_content_rect(rect);
|
||||
|
||||
if(callback_value_changed_) {
|
||||
callback_value_changed_(this);
|
||||
}
|
||||
} else {
|
||||
// Inherited.
|
||||
tscrollbar_container::handle_key_up_arrow(modifier, handled);
|
||||
|
|
|
@ -129,8 +129,8 @@ public:
|
|||
|
||||
/***** ***** ***** setters / getters for members ***** ****** *****/
|
||||
|
||||
// FIXME implement
|
||||
void set_callback_value_change(void (*) (twidget* caller)) {}
|
||||
void set_callback_value_change(void (*callback) (twidget* caller))
|
||||
{ callback_value_changed_ = callback; }
|
||||
|
||||
void set_list_builder(tbuilder_grid_ptr list_builder)
|
||||
{ list_builder_ = list_builder; }
|
||||
|
@ -217,6 +217,15 @@ private:
|
|||
/** Contains the builder for the new items. */
|
||||
tbuilder_grid_const_ptr list_builder_;
|
||||
|
||||
/**
|
||||
* This callback is called when the value in the listbox changes.
|
||||
*
|
||||
* @todo the implementation of the callback hasn't been tested a lot and
|
||||
* there might be too many calls. That might happen if an arrow up didn't
|
||||
* change the selected item.
|
||||
*/
|
||||
void (*callback_value_changed_) (twidget*);
|
||||
|
||||
/** Inherited from tcontrol. */
|
||||
const std::string& get_control_type() const
|
||||
{ static const std::string type = "listbox"; return type; }
|
||||
|
|
Loading…
Add table
Reference in a new issue