FW: Popup menu selections



 
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.

I also tried directing the callback to a different class, which is where I
need it
to go anyway, I have roughly this:

CDropInBase * pDropIn = GetActiveDropIn() // returns the dropin I need.
pSubMenu->items().push_back(Gtk::Menu_Helpers::MenuElem::MenuElem("foo menu
option", 
	SigC::slot(*pDropIn, &CDropInBase::Foo)));

This won't even compile. It is basically what I have already done, except
rather than
use *this as the class instance to call into, I am using a different one.

Any ideas? I am also going to post this to the entire list.

Thanks

--Bob


-----Original Message-----
From: rob page [mailto:page rob gmail com] 
Sent: Tuesday, May 31, 2005 8:43 PM
To: Bob Huston
Subject: Re: Popup menu selections

I think you could do it using sigc::bind:

http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/apbs05.html

Rob.

On 5/31/05, Bob Huston <rhuston mitre org> wrote:
>  
>   
>   
> I have a series of menus that are dynamically built so I can alter the
> contents based on whether certain items 
> are present. When one of these menu items is selected, I need to know
which
> one. 
>   
> I build the menu, and sub-menu in the same way: 
>   
> void CMyTree::BuildMenus() 
> { 
> ..... 
>
pSubMenu->items().push_back(Gtk::Menu_Helpers::MenuElem::MenuElem(pDropIn->G
etDisplayString(),
>                                                         
> SigC::slot(*this, &CMyTreeView::on_popup); 
> ...... 
>   
> // pop the menu up.... 
>   
> } 
>   
> void CMyTreeView::on_popup() 
> { 
>     //do whatever is needed. 
> } 
>   
> My issue is that the sub-menu can have any number of options, depending on
> what dropins I have in the system. 
> There is no good way to have a call back per drop in, because I will not
> know what dropins are there, or how many 
> might be there (drop ins are dynamically loaded at startup time).  
>   
> I tried to have the call back for the menu item be a method of the
"pDropIn"
> class,  but the compiler was not happy 
> with anything like: SigC::slot(*this, pDropIn->PopUPCallback() )  ( I
tried
> several variations wiht &, * and other items.) 
>   
> Is there a way to either: 
>   
> - attach some "marker" or "tag" to each menu item, so I can figure out
what
> is selected? 
> - redirect the menu callback into an instantiated virtual class via  a ptr
> to the base class? 
>   
> I saw a "get_active" method in the menu documentation, it seems to return
a
> Menu Item, but the online documnetation 
> is very weak with telling you what the methods actually do. 
>   
> Thanks for any help. 
>   
> --Bob 
>   
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
> 
> 
>






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