Bug #4767 » test.cpp
1 |
#include <Wt/WStandardItemModel>
|
---|---|
2 |
#include <Wt/WStandardItem>
|
3 |
#include <Wt/WTableView>
|
4 |
|
5 |
namespace
|
6 |
{
|
7 |
class TestPopupHeader |
8 |
: public Wt::WApplication |
9 |
{
|
10 |
public:
|
11 |
TestPopupHeader( const Wt::WEnvironment& env ) |
12 |
: Wt::WApplication( env ) |
13 |
{
|
14 |
root()->setAttributeValue( "oncontextmenu", "event.cancelBubble = true; event.returnValue = false; return false;" ); |
15 |
|
16 |
Wt::WStandardItemModel* model = new Wt::WStandardItemModel( 0, 2 ); |
17 |
model->setHeaderData( 0, Wt::Horizontal, std::string( "xxxxxxx" ) ); |
18 |
model->setHeaderData( 1, Wt::Horizontal, std::string( "xxxxxxx" ) ); |
19 |
for( auto i = 0; i < 1; i++ ) |
20 |
{
|
21 |
auto s = std::to_string( i ); |
22 |
model->appendRow( { new Wt::WStandardItem( s + ", 0" ), new Wt::WStandardItem( s + ", 1" ) } ); |
23 |
}
|
24 |
|
25 |
auto t = new Wt::WTableView; |
26 |
t->setModel( model ); |
27 |
t->setAlternatingRowColors( false ); |
28 |
t->setSortingEnabled( false ); |
29 |
t->setSelectionMode( Wt::NoSelection ); |
30 |
t->mouseWentUp().connect( SLOT( this, TestPopupHeader::ShowPopupMenu ) ); |
31 |
t->setRowHeaderCount( 1 ); |
32 |
root()->addWidget( t ); |
33 |
}
|
34 |
void ShowPopupMenu( const Wt::WModelIndex& item, const Wt::WMouseEvent& e ) |
35 |
{
|
36 |
Wt::WPopupMenu* popup = new Wt::WPopupMenu; |
37 |
popup->addItem( "x" ); |
38 |
popup->popup( e ); |
39 |
}
|
40 |
};
|
41 |
}
|