|
#include <Wt/WBootstrap5Theme.h>
|
|
|
|
#include <Wt/WApplication.h>
|
|
#include <Wt/WContainerWidget.h>
|
|
#include <Wt/WGridLayout.h>
|
|
#include <Wt/WHBoxLayout.h>
|
|
#include <Wt/WMenu.h>
|
|
#include <Wt/WPopupMenu.h>
|
|
#include <Wt/WVBoxLayout.h>
|
|
|
|
#include <Wt/WText.h>
|
|
|
|
using namespace std;
|
|
using namespace Wt;
|
|
|
|
#define SET_BS5THEME 1
|
|
|
|
// Always apply theme before creating widgets!
|
|
class CThemedApplication : public WApplication
|
|
{
|
|
public:
|
|
CThemedApplication(const WEnvironment& rcEnv)
|
|
: WApplication{rcEnv}
|
|
{
|
|
#if SET_BS5THEME
|
|
setTheme(make_shared<WBootstrap5Theme>());
|
|
#endif
|
|
}
|
|
};
|
|
|
|
class CApplication final : public CThemedApplication
|
|
{
|
|
public:
|
|
CApplication(const WEnvironment& rcEnv);
|
|
|
|
private:
|
|
WContainerWidget& root_{*root()};
|
|
|
|
unique_ptr<WPopupMenu> popupMenu_{make_unique<WPopupMenu>()};
|
|
};
|
|
|
|
CApplication::CApplication(const WEnvironment& rcEnv)
|
|
: CThemedApplication{rcEnv}
|
|
{
|
|
setTitle("bug repro " WT_VERSION_STR);
|
|
|
|
popupMenu_->addItem("(no) action");
|
|
|
|
WBoxLayout& layout{*root_.setLayout(make_unique<WHBoxLayout>())};
|
|
layout.setSpacing(20);
|
|
WText& text1{*layout.addWidget(make_unique<WText>("popup(WWidget*)"))};
|
|
WText& text2{*layout.addWidget(make_unique<WText>("popup(const WMouseEvent&)"))};
|
|
text1.mouseWentUp().connect([&text1, this]
|
|
{
|
|
text1.setText("clicked");
|
|
popupMenu_->popup(&text1);
|
|
});
|
|
text2.mouseWentUp().connect([&text2, this](const WMouseEvent& mouse)
|
|
{
|
|
text2.setText("clicked");
|
|
popupMenu_->popup(mouse);
|
|
});
|
|
layout.addStretch(100);
|
|
}
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
return WRun(argc, argv, [](const WEnvironment& rcEnv)
|
|
{
|
|
try
|
|
{
|
|
return make_unique<CApplication>(rcEnv);
|
|
}
|
|
catch (const std::exception& rcException)
|
|
{
|
|
cerr << "exception " << typeid(remove_cvref<decltype(rcException)>::type).name() << ": " << rcException.what() << endl;
|
|
|
|
#if DEBUG
|
|
exit(-1);
|
|
#endif
|
|
throw;
|
|
}
|
|
});
|
|
}
|