[Dropdown menu] What is a SubMenuItem?
Added by Plug Gulp over 12 years ago
Hello,
I am going through the menu example here: http://kipwip.webtoolkit.eu/widgets/navigation/menu
The description there says "You can create items with submenus by using the WSubMenuItem rather than the default WMenuItem." What is a WSubMenuItem? There is just a header file in the source tree and it just includes WMenuItem header. The reason I stumbled upon this file is because I am writing an example to test using Wt the "Dropdown" menu as shown here: http://twitter.github.com/bootstrap/examples/hero.html
How do I achieve that dropdown submenu with Wt?
Following is what I tried, but the output looks bit compromised (screenshot attached):
<code class="cpp">
class MenuItemWidgetApp : public WApplication
{
    public:
        MenuItemWidgetApp(const WEnvironment& env)
            : WApplication(env)
        {
            setTheme(new WBootstrapTheme());
            addMetaHeader("viewport", "width = device-width, initial-scale = 1");
            root()->addStyleClass("container-fluid");
            WMenuItem *mi = new WMenuItem("Menu Item 11");
            WMenu *sm = new WMenu();
            sm->addItem(mi);
            WMenu *m = new WMenu();
            m->addMenu("Test 1", sm);
            m->addItem("Test 2");
            m->addItem("Test 3");
            WNavigationBar *n = new WNavigationBar(root());
            n->setResponsive(true);
            n->addMenu(m);
        }
};
</code>
How do I achieve the dropdown menu in a navigation bar?
Thanks and regards,
~Plug
| NavBarDropdown.png (30.6 KB) NavBarDropdown.png | Screenshot | 
Replies (2)
RE: [Dropdown menu] What is a SubMenuItem? - Added by Koen Deforche over 12 years ago
Hey,
You're right about the inaccurate wording --- the library was in flux at the time this was being written. WSubMenuItem (and WPopupMenuItem) have been merged into WMenuItem.
If however you want to associate a drop down menu with a menu item in a navigation bar, then you need to use a WPopupMenu.
Regards,
koen
RE: [Dropdown menu] What is a SubMenuItem? - Added by Plug Gulp over 12 years ago
Yep, worked with WPopupMenu. Looks gorgeous! (screenshot attached)
Thanks a lot!
Kind regards,
~Plug
| NavBarPopupMenu.png (29.7 KB) NavBarPopupMenu.png | Screenshot |