Home » U++ Library support » Menus&Toolbars » Creating sub menus without callback functions
Re: Creating sub menus without callback functions [message #5901 is a reply to message #5899] |
Tue, 24 October 2006 02:32   |
 |
mirek
Messages: 14267 Registered: November 2005
|
Ultimate Member |
|
|
No, current menu is designed to use callback.
BUT callbacks are quite versatile. This problem can be easily solved by passing additional parameter in the callback.
E.g. like this: (very barebone skeleton, just to get the idea):
struct MyApp {
typedef MyApp CLASSNAME;
Vector<String> top;
Vector< Vector<String> > submenu;
void Action(int top, int i) { /* some action */ }
void SubMenu(Bar& bar, int top) {
const Vector<String>& sm = submenu[top];
for(int i = 0; i < sm.GetCount(); i++)
bar.Add(sm[i], THISBACK2(Action, top, i));
}
void MainMenu(Bar& bar) {
for(int i = 0; i < top.GetCount(); i++)
bar.Add(top[i], THISBACK1(SubMenu, i));
}
....
};
|
|
|
Goto Forum:
Current Time: Mon Aug 18 15:12:12 CEST 2025
Total time taken to generate the page: 0.06570 seconds
|