class TestPopupSubMenu : public Wt::WApplication { public: TestPopupSubMenu( const Wt::WEnvironment& env ) : Wt::WApplication( env ) { auto b = root()->addNew< Wt::WPushButton >( "show WPopupMenu" ); b->clicked().connect( [=]( const Wt::WMouseEvent& me ) { auto popup = root()->addChild(std::make_unique()); auto item = popup->addItem( "0" ); item->triggered().connect( [=] { root()->addNew< Wt::WBreak >(); root()->addNew< Wt::WLabel >( "triggered 0" ); }); auto sub = std::make_unique< Wt::WPopupMenu >(); auto subItem = sub->addItem( "1" ); subItem->triggered().connect( [=] { root()->addNew< Wt::WBreak >(); root()->addNew< Wt::WLabel >( "triggered 1" ); }); item->setMenu( std::move( sub ) ); item->setSelectable( true ); popup->popup( me ); }); } };