Actions
Bug #11478
openWMenuItem triggered can occur multiple times
Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
03/30/2023
Due date:
% Done:
0%
Estimated time:
Description
Wt 4.8.1
After opening the WPopupMenu, clicking quickly on the only item the "clicked!" output shows more than once.
This can be reproduced well on chrome in the developer mode if you enable throttling -> Slow 3g
class TestPopupMenuClick
: public Wt::WApplication
{
public:
TestPopupMenuClick( const Wt::WEnvironment& env )
: Wt::WApplication( env )
{
auto w = root()->addNew< Wt::WPushButton >( "Show WPopupMenu" );
w->clicked().connect
( this
, [=]( const Wt::WMouseEvent& me )
{
auto menu = root()->addChild( std::make_unique< Wt::WPopupMenu >() );
auto item = menu->addItem( "Click me multiple times." );
auto x = item->triggered().connect( this, []{ std::cout << "Clicked!" << std::endl; } );
menu->popup( me );
});
}
};
Updated by Markus S over 1 year ago
My workaround for the issue is as follows:
//...
auto c = std::make_shared< Wt::Signals::connection >();
*c = item->triggered().connect( this, [c]{ c->disconnect(); std::cout << "Clicked!" << std::endl; } );
//...
It is not pretty, but it seems to work.
Actions