⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Wt
All Projects
Wt
Overview
Activity
Roadmap
Issues
Wiki
Forums
Download (1.27 KB)
Bug #3996
ยป Example.cpp
Markus S
, 04/20/2015 04:48 PM
namespace
{
void
ShowPopupMenu
(
Wt
::
WMouseEvent
e
)
{
auto
popup
=
new
Wt
::
WPopupMenu
();
popup
->
addItem
(
"MenuItem 1"
);
popup
->
popup
(
e
);
}
class
ItemDelegate
:
public
Wt
::
WItemDelegate
{
public:
ItemDelegate
()
:
Wt
::
WItemDelegate
()
{}
virtual
Wt
::
WWidget
*
update
(
Wt
::
WWidget
*
widget
,
const
Wt
::
WModelIndex
&
index
,
Wt
::
WFlags
<
Wt
::
ViewItemRenderFlag
>
flags
)
override
{
auto
w
=
Wt
::
WItemDelegate
::
update
(
widget
,
index
,
flags
);
if
(
auto
interactWidget
=
dynamic_cast
<
Wt
::
WInteractWidget
*
>
(
w
)
)
interactWidget
->
mouseWentUp
().
connect
(
ShowPopupMenu
);
return
w
;
}
};
class
TestTableViewOpensTwoPopupMenus
:
public
Wt
::
WApplication
{
public:
TestTableViewOpensTwoPopupMenus
(
const
Wt
::
WEnvironment
&
env
)
:
Wt
::
WApplication
(
env
)
{
auto
tableView
=
new
Wt
::
WTableView
();
auto
model
=
new
Wt
::
WStandardItemModel
();
tableView
->
setModel
(
model
);
tableView
->
setHeaderItemDelegate
(
new
ItemDelegate
()
);
tableView
->
mouseWentUp
().
connect
(
[](
Wt
::
WModelIndex
,
Wt
::
WMouseEvent
e
,
...
){
ShowPopupMenu
(
e
);
}
);
model
->
appendRow
({
new
Wt
::
WStandardItem
(
"Data"
)
});
model
->
setHeaderData
(
0
,
boost
::
any
(
std
::
string
(
"Header"
)
)
);
root
()
->
addWidget
(
tableView
);
}
};
}
(1-1/1)
Loading...