Support #2418 » bug2418.cpp
1 |
#include <Wt/WApplication>
|
---|---|
2 |
#include <Wt/WContainerWidget>
|
3 |
#include <Wt/WPushButton>
|
4 |
#include <Wt/WText>
|
5 |
|
6 |
using namespace Wt; |
7 |
|
8 |
class MyApp : public WApplication |
9 |
{
|
10 |
public:
|
11 |
|
12 |
MyApp(const WEnvironment& env) |
13 |
: WApplication(env) |
14 |
{
|
15 |
WPushButton* button1 = new WPushButton( "Button 1", root() ); |
16 |
button1->clicked().connect( this, &MyApp::changePath1 ); |
17 |
|
18 |
WPushButton* button2 = new WPushButton( "Button 2", root() ); |
19 |
button2->clicked().connect( this, &MyApp::changePath2 ); |
20 |
|
21 |
internalPathChanged().connect( this, &MyApp::handlePathChange ); |
22 |
}
|
23 |
|
24 |
void changePath1() { |
25 |
std::cerr << "Button1 clicked" << std::endl; |
26 |
setInternalPath( "/page1", false ); |
27 |
}
|
28 |
|
29 |
void changePath2() { |
30 |
std::cerr << "Button2 clicked" << std::endl; |
31 |
setInternalPath( "/page2", true ); |
32 |
}
|
33 |
|
34 |
void handlePathChange( std::string path ) |
35 |
{
|
36 |
std::cout << "handlePathChange " << path << std::endl; |
37 |
}
|
38 |
};
|
39 |
|
40 |
WApplication *createMyApplication(const WEnvironment& env) |
41 |
{
|
42 |
return new MyApp(env); |
43 |
}
|
44 |
|
45 |
int main(int argc, char **argv) |
46 |
{
|
47 |
return WRun(argc, argv, &createMyApplication); |
48 |
}
|