aaa
C++
code posted
by
ogata
created at 31 Dec 18:33
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
#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); } |
1.45 KB in 3 ms with coderay