|
#ifndef _BUGREPRO_BUTTONGROUP_SIGNAL_HPP
|
|
#define _BUGREPRO_BUTTONGROUP_SIGNAL_HPP
|
|
|
|
#include <Wt/WRadioButton.h>
|
|
#include <Wt/WButtonGroup.h>
|
|
#include <Wt/WContainerWidget.h>
|
|
#include <Wt/WText.h>
|
|
#include <Wt/WBreak.h>
|
|
|
|
namespace Bugrepro
|
|
{
|
|
namespace ButtonGroup_Signal
|
|
{
|
|
|
|
struct TestWidget : public Wt::WContainerWidget
|
|
{
|
|
TestWidget();
|
|
|
|
// private:
|
|
// void createLayout();
|
|
// void setupConnections();
|
|
|
|
private:
|
|
Wt::WRadioButton *rbtn_ONE, *rbtn_TWO;
|
|
std::shared_ptr<Wt::WButtonGroup> btnGroup;
|
|
|
|
Wt::WText *txt_Clicked, *txt_Changed;
|
|
};
|
|
|
|
TestWidget::TestWidget()
|
|
{
|
|
addNew<Wt::WText>("Signal from Radio Button Groups Signal 'checkedChanged' does not always return checked Button:");
|
|
|
|
addNew<Wt::WBreak>();
|
|
|
|
rbtn_ONE = addNew<Wt::WRadioButton>("Radio ONE");
|
|
rbtn_TWO = addNew<Wt::WRadioButton>("Radio TWO");
|
|
|
|
btnGroup = std::make_shared<Wt::WButtonGroup>();
|
|
|
|
btnGroup->addButton(rbtn_ONE);
|
|
btnGroup->addButton(rbtn_TWO);
|
|
|
|
addNew<Wt::WBreak>();
|
|
txt_Changed = addNew<Wt::WText>("Group Changed Signal: ");
|
|
addNew<Wt::WBreak>();
|
|
txt_Clicked = addNew<Wt::WText>("Button Clicked Signal: ");
|
|
|
|
|
|
btnGroup->checkedChanged().connect([this](Wt::WRadioButton *btn){
|
|
if(btn == this->rbtn_ONE)
|
|
{
|
|
this->txt_Changed->setText("Group Changed Signal: 'Radio ONE'");
|
|
return;
|
|
}
|
|
if(btn == this->rbtn_TWO)
|
|
{
|
|
this->txt_Changed->setText("Group Changed Signal: 'Radio TWO'");
|
|
return;
|
|
}
|
|
this->txt_Changed->setText(Wt::WString("Group Changed Signal: Not Recognised: Index {1}").arg(this->btnGroup->selectedButtonIndex()));
|
|
});
|
|
|
|
rbtn_ONE->clicked().connect([this](){
|
|
this->txt_Clicked->setText("Button Clicked Signal: 'Radio ONE");
|
|
});
|
|
rbtn_TWO->clicked().connect([this](){
|
|
this->txt_Clicked->setText("Button Clicked Signal: 'Radio TWO");
|
|
});
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#endif // _BUGREPRO_BUTTONGROUP_SIGNAL_HPP
|