Popup menu selections



 
 
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->GetDisplayString(),
                                                         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
 


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