Don't uncheck a radiobutton on second click.

This commit is contained in:
John Preston 2017-07-18 20:11:44 +03:00
parent 794ad7bda7
commit 077e128e9a
2 changed files with 11 additions and 10 deletions

View File

@ -408,11 +408,15 @@ void Checkbox::onStateChanged(State was, StateChangeSource source) {
auto now = state();
if (!isDisabled() && (was & StateFlag::Over) && (now & StateFlag::Over)) {
if ((was & StateFlag::Down) && !(now & StateFlag::Down)) {
setChecked(!checked());
handlePress();
}
}
}
void Checkbox::handlePress() {
setChecked(!checked());
}
int Checkbox::resizeGetHeight(int newWidth) {
return _check->getSize().height();
}
@ -461,14 +465,9 @@ void Radiobutton::handleNewGroupValue(int value) {
}
}
void Radiobutton::onStateChanged(State was, StateChangeSource source) {
Checkbox::onStateChanged(was, source);
auto now = state();
if (!isDisabled() && (was & StateFlag::Over) && (now & StateFlag::Over)) {
if ((was & StateFlag::Down) && !(now & StateFlag::Down)) {
_group->setValue(_value);
}
void Radiobutton::handlePress() {
if (!checkbox()->checked()) {
checkbox()->setChecked(true);
}
}

View File

@ -148,6 +148,8 @@ protected:
QImage prepareRippleMask() const override;
QPoint prepareRippleStartPosition() const override;
virtual void handlePress();
void updateCheck() {
rtlupdate(_checkRect);
}
@ -209,7 +211,7 @@ public:
~Radiobutton();
protected:
void onStateChanged(State was, StateChangeSource source) override;
void handlePress() override;
private:
// Hide the names from Checkbox.