Project

General

Profile

Bug #1370 ยป example.cpp

Anonymous, 07/26/2012 01:51 PM

 

#include <Wt/WApplication>
#include <Wt/WEnvironment>
#include <Wt/WDialog>
#include <Wt/WText>
#include <Wt/WBreak>
#include <Wt/WPushButton>
#include <Wt/WLineEdit>

using namespace Wt;

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

static Wt::WApplication* CreateApplication(const Wt::WEnvironment& env)
{
return new Playground(env);
}
};

Playground::Playground (const WEnvironment& env)
: WApplication(env)
{
Wt::WDialog dialog("Personalia");

new Wt::WText("Enter your name: ", dialog.contents());
Wt::WLineEdit edit(dialog.contents());
new Wt::WBreak(dialog.contents());

Wt::WPushButton ok("Ok", dialog.contents());

// these events will accept() the Dialog
edit.enterPressed().connect(&dialog, &Wt::WDialog::accept);
ok.clicked().connect(&dialog, &Wt::WDialog::accept);

if (dialog.exec() == Wt::WDialog::Accepted) {
// NOP
}
}

int main (int argc, char **argv)
{
return WRun(argc, argv, &Playground::CreateApplication);
}

    (1-1/1)