Title / Description
Code #include <Wt/WApplication> #include <Wt/WText> #include <Wt/WBreak> #include <Wt/WPopupMenu> using namespace Wt; class my_app: public WApplication { public: my_app(const WEnvironment& env); private: WText* _text1; void item1(); void item2(); void subitem1(); }; my_app::my_app(const WEnvironment& env) : WApplication(env) { _text1 = new WText("-----", root()); new WBreak(root()); WPopupMenu* _popup1 = new WPopupMenu(); WPopupMenuItem* item1 = _popup1->addItem("Item 1"); item1->triggered().connect(this, &my_app::item1); WPopupMenuItem* item2 = _popup1->addItem("Item 2"); item2->triggered().connect(this, &my_app::item2); WPopupMenu* _popup2 = new WPopupMenu(); WPopupMenuItem* subitem1 = _popup2->addItem("Sub Item 1"); subitem1->triggered().connect(this, &my_app::subitem1); _popup1->addMenu("xxx", _popup2); WText* text = new WText("Clicking here will show a popup menu.", root()); text->clicked().connect(_popup1, &WPopupMenu::popup); } void my_app::item1() { _text1->setText("item1"); } void my_app::item2() { _text1->setText("item2"); } void my_app::subitem1() { // code is not reaching here _text1->setText("subitem1"); } WApplication* createApplication(const WEnvironment& env) { return new my_app(env); } int main(int argc, char** argv) { return WRun(argc, argv, &createApplication); }
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code