namespace { class TestPopupMenu : public Wt::WApplication { public: TestPopupMenu( const Wt::WEnvironment& env ) : Wt::WApplication( env ) { root()->setAttributeValue( "oncontextmenu", "event.cancelBubble = true; event.returnValue = false; return false;" ); Wt::WLabel* w = new Wt::WLabel( "show WPopupMenu", root() ); w->mouseWentUp().connect( SLOT( this, TestPopupMenu::ShowPopupMenu ) ); } void ShowPopupMenu( const Wt::WMouseEvent& me ) { Wt::WPopupMenu* popup = new Wt::WPopupMenu; popup->addItem( "fast" ); popup->addItem( "fast" ); auto item = popup->addItem( "SLOW" ); item->triggered().connect( boost::bind( &TestPopupMenu::Click, this ) ); //item->triggered().connect( [&]() //{ // Sleep( 10000 ); //}); popup->addItem( "fast" ); popup->addItem( "fast" ); popup->popup( me ); } void Click() { Sleep( 10000 ); } }; }