Update callback data when menu is going to be clicked

This commit is contained in:
Sanel Zukan 2009-10-08 13:27:36 +00:00
parent 445a252644
commit 9a3b95faf4

View File

@ -74,12 +74,6 @@ TaskButton::TaskButton(int X, int Y, int W, int H, const char *l) : Fl_Button(X,
box(FL_UP_BOX);
align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_CLIP);
/* parameters for callbacks */
menu_[0].user_data(this);
menu_[1].user_data(this);
menu_[2].user_data(this);
menu_[3].user_data(this);
if(IconLoader::inited()) {
Fl_Shared_Image *img = IconLoader::get("process-stop", ICON_SIZE_TINY);
menu_[3].image((Fl_Image*)img);
@ -133,6 +127,12 @@ void TaskButton::display_menu(void) {
/* do not popup tooltip when the menu is on */
tooltip(NULL);
/* parameters for callbacks; this is done here, since menu_ is static and shared between buttons */
menu_[0].user_data(this);
menu_[1].user_data(this);
menu_[2].user_data(this);
menu_[3].user_data(this);
const MenuItem *item = menu_->popup(Fl::event_x(), Fl::event_y(), 0, 0, 0);
if(item && item->callback())
item->do_callback(this);