Add a helper macro for setting standard button callbacks in a dialog.
Yes, it's a macro, but it can reduce the copy-paste factor of a pre_show() function quite a lot when there are many buttons.
This commit is contained in:
parent
9fe323644d
commit
c538e687c3
1 changed files with 6 additions and 0 deletions
|
@ -33,6 +33,12 @@ void dialog_callback(twidget* caller)
|
|||
(dialog->*fptr)(*window);
|
||||
}
|
||||
|
||||
#define GUI2_EASY_BUTTON_CALLBACK(ID, MY_TYPE) \
|
||||
tbutton* ID##_btn = dynamic_cast<tbutton*>(window.find_widget(#ID, false)); \
|
||||
VALIDATE(ID##_btn, missing_widget(#ID)); \
|
||||
ID##_btn->set_callback_mouse_left_click(dialog_callback<MY_TYPE, \
|
||||
&MY_TYPE::ID##_button_callback>);
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue