Add callback function when clicking.
This commit is contained in:
parent
6b06fa5ac6
commit
c680ac76df
2 changed files with 14 additions and 4 deletions
|
@ -83,7 +83,9 @@ void tbutton::mouse_left_button_click(tevent_handler&)
|
|||
}
|
||||
}
|
||||
|
||||
// Do the custom handling (not implemented yet) FIXME
|
||||
if(callback_mouse_left_click_) {
|
||||
callback_mouse_left_click_(this);
|
||||
}
|
||||
}
|
||||
|
||||
tbutton::RETVAL tbutton::get_retval_by_id(const std::string& id)
|
||||
|
|
|
@ -26,7 +26,8 @@ public:
|
|||
tbutton() :
|
||||
tcontrol(COUNT),
|
||||
state_(ENABLED),
|
||||
retval_(0)
|
||||
retval_(0),
|
||||
callback_mouse_left_click_(0)
|
||||
{
|
||||
load_config();
|
||||
}
|
||||
|
@ -60,8 +61,9 @@ public:
|
|||
bool get_active() const;
|
||||
unsigned get_state() const { return state_; }
|
||||
|
||||
protected:
|
||||
|
||||
void set_callback_mouse_left_click(void (*callback) (twidget*))
|
||||
{ callback_mouse_left_click_ = callback; }
|
||||
|
||||
private:
|
||||
//! Note the order of the states must be the same as defined in settings.hpp.
|
||||
enum tstate { ENABLED, DISABLED, PRESSED, FOCUSSED, COUNT };
|
||||
|
@ -71,6 +73,12 @@ private:
|
|||
|
||||
int retval_;
|
||||
|
||||
/**
|
||||
* This callback is used when the control gets a left click. Except when the
|
||||
* button has a retval_, then retval_ is set.
|
||||
*/
|
||||
void (*callback_mouse_left_click_) (twidget*);
|
||||
|
||||
//! Inherited from tcontrol.
|
||||
const std::string& get_control_type() const
|
||||
{ static const std::string type = "button"; return type; }
|
||||
|
|
Loading…
Add table
Reference in a new issue