Popup menu callbacks not executed



I want to display a popup menu from my main window, I've based the code from the docs:

http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch10.html

I'm using gtkmm-2.2.9 on a Fedora Core 1 ( and no I can't upgrade to gtkmm-2.4 the program is tooo big for doing the upgrade, at least for the moment).


The menu is displayed well, but the callbacks (signal) associated to the submenus are not executed.

Lest go to the code:

.hh:

 Gtk::Menu *menu_popup;
 Gtk::Menu *sub_menu1;

.cc:

 The popup menu calling code:

if(!(ev->state&GDK_BUTTON1_MASK)&&!(ev->state&GDK_BUTTON2_MASK)&&(ev->state&GDK_BUTTON3_MASK))
 {
   if(this->configurar_menu_popup()>=0)
     this->menu_popup->popup(ev->button,ev->time);
   return true;
 }


 The popupmenu configuration code:

gint window1::configurar_menu_popup()
{
 if(!this->sub_menu1)
 {
   this->sub_menu1 = new Gtk::Menu();
 }
 if(!this->menu_popup)
 {
   this->menu_popup = new Gtk::Menu();
 }

 // Clear the submenu
 this->sub_menu1->items().clear();
 // Clear the main menu
 this->menu_popup->items().clear();


 Gtk::Menu::MenuList& menulist = this->menu_popup->items();

 menulist.push_back(Gtk::Menu_Helpers::MenuElem("_Centrar Barco",
						 SigC::slot(*this,&window1::centrar_barco)));
 menulist.push_back(Gtk::Menu_Helpers::MenuElem("_Lista Cartas",
						 SigC::slot(*this,&window1::on_carga_carta1_activate)));


 Gtk::Menu::MenuList& menulist1 = this->sub_menu1->items();

 menulist1.push_back(Gtk::Menu_Helpers::MenuElem("Maxima",
						  SigC::slot(*this,&window1::maxima_lat_lon)));
 menulist1.push_back(Gtk::Menu_Helpers::MenuElem("Media",
						  SigC::slot(*this,&window1::media_lat_lon)));
 menulist1.push_back(Gtk::Menu_Helpers::MenuElem("Minima",
						  SigC::slot(*this,&window1::minima_lat_lon)));
 menulist1.push_back(Gtk::Menu_Helpers::MenuElem("Desactivar",
						  SigC::slot(*this,&window1::desactivar_lat_lon)));


menulist.push_back(Gtk::Menu_Helpers::MenuElem("_Regleta",*this->sub_menu1));

 this->menu_popup->accelerate(*this);

 show_all_children();

 return true;
}





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]