RE: FW: Popup menu selections



Thanks to everyone for the help.  Feeling a bit stupid here, but...

it works, using the SigC::bind mentioned below it is now working. The issue
I had with it being a null when it got into my callback, I believe was the
complier optimizing the variable away since I wasn't using it.

I added two lines to the method:

Glib::ustring str2;
str2=str;

and it worked. Not sure why the compiler optimized it out, but in any case
it is now working and I am off and running.

Thanks!
 

-----Original Message-----
From: Bob Caryl [mailto:bob fis-cal com] 
Sent: Wednesday, June 01, 2005 11:01 AM
To: Bob Huston
Cc: gtkmm-list gnome org
Subject: 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]