Wt::WPopupMenu and Main Window
Added by Patrick ottavi about 4 years ago
Hello,
I try to implement a change of view on a submenu without success,
when I add an item to the main menu it works,
but not on an item in the submenu. anyone have any idea for this problem?
for example with this code it works:
auto navigation_ = Wt::cpp14::make_unique<Wt::WNavigationBar>();
navigation = navigation_.get();
navigation->addStyleClass("navbar navbar-inverse");
string url = "/Acceuil";
navigation->setTitle(GetApplicationName(), Wt::WLink(Wt::LinkType::InternalPath, url));
navigation->setResponsive(true);
auto contentsStack_ = Wt::cpp14::make_unique<Wt::WStackedWidget>();
contentsStack = contentsStack_.get();
contentsStack->addStyleClass("contents");
Wt::WAnimation animation(AnimationEffect::Fade, TimingFunction::Linear, 200);
contentsStack->setTransitionAnimation(animation, true);
// Setup a Left-aligned menu.
auto menu = cpp14::make_unique< Wt::WMenu>(contentsStack);
m_leftMenu = menu.get();
m_leftMenu->addItem(L"Accueil", deferCreate(std::bind(&VisualMarketApp::Acceuil, this)));
m_leftMenu->addItem(L"Item1", deferCreate(std::bind(&VisualMarketApp::Products, this)));
m_leftMenu->addItem(L"Item2", deferCreate(std::bind(&VisualMarketApp::Products, this)));
....
navigation->addMenu(std::move(menu));
if I try with a sub menu it doesn't work.
vector<string> arFamTitle = { "Item1","Item2"};
auto popup = Wt::cpp14::make_unique<Wt::WPopupMenu>();
m_popup = popup.get();
m_leftMenu->addMenu("", "Produits", std::move(popup));
for (int i = 0; i < arFam.size(); i++)
{
m_popup->addItem(arFamTitle[i], deferCreate(std::bind(&VisualMarketApp::Products, this)));
}
navigation->addMenu(std::move(menu));
is there a solution to change view with a submenu?
Patrick