Project

General

Profile

Bug #2527 ยป SetPath.cpp

Koen Deforche, 02/07/2014 09:39 PM

 
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* button = new WPushButton( "click to see alice", root() );
16
        button->clicked().connect( this, &MyApp::changePath );
17
        internalPathChanged().connect( this, &MyApp::handlePathChange );
18

    
19
	setInternalPath("/login");
20
    }
21

    
22
    void changePath() { setInternalPath( "/alice/", true ); }
23

    
24
    void handlePathChange( std::string path )
25
    {
26
        std::cout << "handlePathChange " << path << std::endl;
27
        new WText( path, root() );
28
    }
29
};
30

    
31
WApplication *createMyApplication(const WEnvironment& env)
32
{
33
    return new MyApp(env);
34
}
35

    
36
int main(int argc, char **argv)
37
{
38
    return WRun(argc, argv, &createMyApplication);
39
}
    (1-1/1)