Dear witty guys,

I would like to connect something to a WPopupMenuItem.triggered signal
somewhere else than it was created. However, I cannot do this, because
the root()->find() method cannot find the menuitem. Example code is
attached.

Thanks,
Gabor
#include <iostream>
#include <stdio.h>
#include <Wt/WContainerWidget>
#include <Wt/WApplication>
#include <Wt/WPopupMenu>
#include <Wt/WPopupMenuItem>
#include <Wt/WText>
#include <Wt/WLabel>

using namespace Wt;
using namespace std;

class MyApplication : public WApplication {
	public:

		MyApplication(const WEnvironment& environment) : WApplication(environment) {
			WPopupMenu *popup = new WPopupMenu;
			WPopupMenuItem *item = popup->addItem("Item 1");
			item->setObjectName("ThisIsItem1");
			popup->add( item );
			popup->addItem("Item 2")->setCheckable(true);
			WPopupMenu *subMenu = new WPopupMenu();
			subMenu->addItem("Sub Item 1");
			subMenu->addItem("Sub Item 2");
			popup->addMenu("Item 3", subMenu);

			WLabel* clickMe = new WLabel("Clicking here will show a popup menu.");
			clickMe->setStyleClass("popupmenuLabel");
			clickMe->clicked().connect(popup, &WPopupMenu::popup);

			root()->addWidget( clickMe );
			root()->addWidget( new WBreak() );

			if (root()->find("ThisIsItem1")) 
				root()->addWidget( new WText("Item 1 has been found") );
			else
				root()->addWidget( new WText("Item 1 has not been found") );
		}
		
};

WApplication *createApplication(const WEnvironment& env) {
	
	WApplication *app = new MyApplication(env);

	return app;
}

int main(int argc, char **argv)
{
   return WRun(argc, argv, &createApplication);
}

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to