Re: FW: Popup menu selections



Bob Huston wrote:


thanks for the pointer, it helped a bit, and pointed me at some other
options
as well. Unfortunately, I can't get any to work.

I modified my menu build to be:

pSubMenu->items().push_back(Gtk::Menu_Helpers::MenuElem::MenuElem("foo menu
option",
                     SigC::bind<glib::ustring>(SigC::slot(*this,
&CMyTreeView::on_popup), "foo")));
and changed the call back to:

void CMyTreeView::on_popup(Glib::ustring str) { //do whatever is needed. } rebuild and run, setting a break point in on_popup. The break is hit,
however, the
passed parameter str is null.
typedef SigC::Slot0<void> Gtk::Menu_Helpers::Element::CallSlot

The problem I see with the above code is that the Gtk::Menu_Helpers::MenuElem::MenuElem function is prototyped this way: MenuElem (const Glib::ustring& label, const CallSlot& slot=CallSlot())

and CallSlot is prototyped this way:

   typedef SigC::Slot0<void> Gtk::Menu_Helpers::Element::CallSlot

Note the SigC::Slot0 template shows only a return value for the slot... NO formal paramters are expected and so, even though you are attempting to bind a Glib::ustring so that you can identify which menu item is being processed by a single callback slot, the parameter for your callback slot is always null. I realize it's feckless to only tell you why what you're trying doesn't work and I'm sorry for that. What you're trying will probably only work with the "connect" method associated with class signal methods such as "Gtk::Button::signal_clicked".

Bob Caryl






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