U++ framework
Do not panic. Ask here before giving up.

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 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14291
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));
    }

    ....
};

 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: DropList bug
Next Topic: MenuBar.Execute seems to ignore owner - Bug?
Goto Forum:
  


Current Time: Tue Jun 23 01:03:36 GMT+2 2026

Total time taken to generate the page: 0.00475 seconds