Project

General

Profile

Bug #1005 ยป hello.C

Pieter Libin, 10/05/2011 05:09 PM

 
#include <Wt/WApplication>
#include <Wt/WLabel>
#include <Wt/WPopupMenu>

using namespace Wt;

class HelloApplication : public WApplication
{
public:
HelloApplication(const WEnvironment& env);

private:
WPopupMenu *m_pMenu;

void popup(const WMouseEvent &me);
};

HelloApplication::HelloApplication(const WEnvironment& env)
: WApplication(env),
m_pMenu(0)
{
WLabel *label = new WLabel("my-label", root());
label->mouseWentUp().connect(this, &HelloApplication::popup);
}

void HelloApplication::popup(const WMouseEvent &me)
{
if( m_pMenu ) {
delete m_pMenu;
m_pMenu = 0;
}
m_pMenu = new WPopupMenu();
m_pMenu->addItem("Menu item");
m_pMenu->popup( me );
}

WApplication *createApplication(const WEnvironment& env)
{
return new HelloApplication(env);
}

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

    (1-1/1)