Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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: 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));
    }

    ....
};

 
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: Mon Aug 18 15:12:12 CEST 2025

Total time taken to generate the page: 0.06570 seconds