Project

General

Profile

Bug #4001 ยป Example.cpp

Markus S, 04/22/2015 11:32 AM

 
namespace
{
class TestContextMenuItemCheckable
: public Wt::WApplication
{
bool myIsChecked = false;
Wt::WDialog* myDialog = nullptr;
public:
TestContextMenuItemCheckable( const Wt::WEnvironment& env )
: Wt::WApplication( env )
, myDialog( new Wt::WDialog() ) // Breaks "MenuItem 2" - comment out line to fix
{
auto button = new Wt::WPushButton( "OpenPopupMenu" );
button->clicked()
.connect( [&]( Wt::WMouseEvent e )
{
auto popup = new Wt::WPopupMenu();
auto item1 = new Wt::WMenuItem( "MenuItem 1" );
auto item2 = new Wt::WMenuItem( "MenuItem 2" );
item2->setCheckable( true );
item2->setChecked( myIsChecked );
popup->addItem( item1 );
popup->addItem( item2 );

auto item = popup->exec( e );
if( item == item1
|| item == item2
)
myIsChecked = !myIsChecked;
});
root()->addWidget( button );
}
};
}
    (1-1/1)