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->configure_menu_popup()>=0)
this->menu_popup->popup(ev->button,ev->time);
return true;
}


The popupmenu configuration code:


gint window1::configure_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("_A",
						 SigC::slot(*this,&window1::func_a)));
menulist.push_back(Gtk::Menu_Helpers::MenuElem("_B",
						 SigC::slot(*this,&window1::func_b)));



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


menulist1.push_back(Gtk::Menu_Helpers::MenuElem("C1",
						  SigC::slot(*this,&window1::func_c1)));
menulist1.push_back(Gtk::Menu_Helpers::MenuElem("C2",
						  SigC::slot(*this,&window1::func_c2)));
menulist1.push_back(Gtk::Menu_Helpers::MenuElem("C3",
						  SigC::slot(*this,&window1::func_c3)));


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

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


show_all_children();


return true;
}


The menu and submen are displayed well, and de "A" and "B" menuitems funcions are executed correctly.

The problem is that de "CX" submenu menuitems functions are never executed when clicking over "CX" elements.


What I'm doing wrong? Have I miss something?





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