[gtkmm] Popup Menu problem



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

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



.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:

/* **************************
  configurar_menu_popup
  *********************** */
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)));


 // Creamos el sub-menu de regleta
 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;
}

_________________________________________________________________
Reserva desde ahora tus vacaciones en MSN Viajes. Más cómodo, más barato y más opciones. http://www.msn.es/Viajes/




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