#include #include #include #include #include #include #include #include #include using namespace std; using namespace Wt; #define SET_BS5THEME 1 // Always apply theme before creating widgets! class CThemedApplication : public WApplication { public: CThemedApplication(const WEnvironment& rcEnv) : WApplication{rcEnv} { #if SET_BS5THEME setTheme(make_shared()); #endif } }; class CApplication final : public CThemedApplication { public: CApplication(const WEnvironment& rcEnv); private: WContainerWidget& root_{*root()}; unique_ptr popupMenu_{make_unique()}; }; CApplication::CApplication(const WEnvironment& rcEnv) : CThemedApplication{rcEnv} { setTitle("bug repro " WT_VERSION_STR); popupMenu_->addItem("(no) action"); WBoxLayout& layout{*root_.setLayout(make_unique())}; layout.setSpacing(20); WText& text1{*layout.addWidget(make_unique("popup(WWidget*)"))}; WText& text2{*layout.addWidget(make_unique("popup(const WMouseEvent&)"))}; text1.mouseWentUp().connect([&text1, this] { text1.setText("clicked"); popupMenu_->popup(&text1); }); text2.mouseWentUp().connect([&text2, this](const WMouseEvent& mouse) { text2.setText("clicked"); popupMenu_->popup(mouse); }); layout.addStretch(100); } int main(int argc, char* argv[]) { return WRun(argc, argv, [](const WEnvironment& rcEnv) { try { return make_unique(rcEnv); } catch (const std::exception& rcException) { cerr << "exception " << typeid(remove_cvref::type).name() << ": " << rcException.what() << endl; #if DEBUG exit(-1); #endif throw; } }); }