From b2b26af9cd8e5d436fdf27d2f266ad3c23f7a192 Mon Sep 17 00:00:00 2001 From: "jcampan@chromium.org" Date: Fri, 24 Apr 2009 18:48:44 +0000 Subject: Fix a bug where radio buttons would become unselected when clicked (more specifically, when clicked on the button, not the label). BUG=10834 TEST=Open the option dialog, click on the button (not the label) of a selected radio-button. The button should stay selected. Make sure checkboxes and radio buttons still behave as expected. Review URL: http://codereview.chromium.org/97012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14447 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/views/controls/button/native_button_win.cc | 3 ++- chrome/views/controls/button/native_button_win.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'chrome') diff --git a/chrome/views/controls/button/native_button_win.cc b/chrome/views/controls/button/native_button_win.cc index a6cf075..5a254ac 100644 --- a/chrome/views/controls/button/native_button_win.cc +++ b/chrome/views/controls/button/native_button_win.cc @@ -160,7 +160,8 @@ bool NativeCheckboxWin::OnKeyDown(int vkey) { bool NativeCheckboxWin::ProcessMessage(UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) { if (message == WM_COMMAND && HIWORD(w_param) == BN_CLICKED) { - checkbox_->SetChecked(!checkbox_->checked()); + if (!IsRadioButton() || !checkbox_->checked()) + checkbox_->SetChecked(!checkbox_->checked()); // Fall through to the NativeButtonWin's handler, which will send the // clicked notification to the listener... } diff --git a/chrome/views/controls/button/native_button_win.h b/chrome/views/controls/button/native_button_win.h index f9dbcaf..ce1cc75e 100644 --- a/chrome/views/controls/button/native_button_win.h +++ b/chrome/views/controls/button/native_button_win.h @@ -75,6 +75,9 @@ class NativeCheckboxWin : public NativeButtonWin { virtual void NativeControlCreated(HWND control_hwnd); virtual bool IsCheckbox() const { return true; } + // Returns true if this button is actually a radio button. + virtual bool IsRadioButton() const { return false; } + private: // The Checkbox we are bound to. Checkbox* checkbox_; @@ -91,6 +94,7 @@ class NativeRadioButtonWin : public NativeCheckboxWin { protected: // Overridden from NativeCheckboxWin: virtual void CreateNativeControl(); + virtual bool IsRadioButton() const { return true; } private: DISALLOW_COPY_AND_ASSIGN(NativeRadioButtonWin); -- cgit v1.1