https://github.com/libsdl-org/Maelstrom/commit/1b6540efde000ae41b5a0096e6bd9bae90d29a48
From 1b6540efde000ae41b5a0096e6bd9bae90d29a48 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 31 Oct 2011 17:16:37 -0400
Subject: [PATCH] You can't click a radio button twice to deselect it, silly.
:)
---
screenlib/UIElementRadio.cpp | 10 +++++++++-
screenlib/UIElementRadio.h | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/screenlib/UIElementRadio.cpp b/screenlib/UIElementRadio.cpp
index ae836446..670b4ace 100644
--- a/screenlib/UIElementRadio.cpp
+++ b/screenlib/UIElementRadio.cpp
@@ -57,7 +57,7 @@ UIElementRadioGroup::RadioButtonChecked(UIElementRadioButton *button)
FindElements<UIElementRadioButton>(buttons);
for (unsigned i = 0; i < buttons.length(); ++i) {
if (buttons[i] != button && buttons[i]->IsChecked()) {
- buttons[i]->OnClick();
+ buttons[i]->SetChecked(false);
}
}
m_value = button->GetID();
@@ -99,6 +99,14 @@ UIElementRadioButton::FinishLoading()
return true;
}
+void
+UIElementRadioButton::OnClick()
+{
+ SetChecked(true);
+
+ UIElementButton::OnClick();
+}
+
void
UIElementRadioButton::OnChecked(bool checked)
{
diff --git a/screenlib/UIElementRadio.h b/screenlib/UIElementRadio.h
index dcac108f..8b3dbe30 100644
--- a/screenlib/UIElementRadio.h
+++ b/screenlib/UIElementRadio.h
@@ -66,6 +66,7 @@ DECLARE_TYPESAFE_CLASS(UIElementCheckbox)
override bool Load(rapidxml::xml_node<> *node, const UITemplates *templates);
override bool FinishLoading();
+ override void OnClick();
override void OnChecked(bool checked);
protected: