]> git.saurik.com Git - wxWidgets.git/commitdiff
Make wxRadioButton::SetValue(true) deselect all other wxRadioButton in its group...
authorDavid Elliott <dfe@tgwbd.org>
Thu, 19 Jul 2007 18:00:32 +0000 (18:00 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Thu, 19 Jul 2007 18:00:32 +0000 (18:00 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47568 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/cocoa/radiobut.h
src/cocoa/radiobut.mm

index bbd0b9595543811b46072b8fb5fec0be7b26b110..2975bcaffbcf7dd2ca59d932c71dcc1b67ed5199 100644 (file)
@@ -56,6 +56,8 @@ public:
 // ------------------------------------------------------------------------
 protected:
     virtual void Cocoa_wxNSButtonAction(void);
+private:
+    void Cocoa_DeselectOtherButtonsInTheGroup(void);
 // ------------------------------------------------------------------------
 // Implementation
 // ------------------------------------------------------------------------
index caaa25001ebba8f333e2ef7d8b3fe6d1443736ef..7054adae238aa51aebaa0cca199f033b6564b39b 100644 (file)
@@ -130,7 +130,10 @@ wxRadioButton::~wxRadioButton()
 void wxRadioButton::SetValue(bool value)
 {
     if(value)
+    {
         [GetNSButton() setState: NSOnState];
+        Cocoa_DeselectOtherButtonsInTheGroup();
+    }
     else
         [GetNSButton() setState: NSOffState];
 }
@@ -142,10 +145,14 @@ bool wxRadioButton::GetValue() const
     return state==NSOnState;
 }
 
-void wxRadioButton::Cocoa_wxNSButtonAction(void)
+/**
+ * If this radio button is part of a group, this method turns off every other
+ * button in the group.  If this radio button is not part of a group, this
+ * method does absolutely nothing.
+ */
+void wxRadioButton::Cocoa_DeselectOtherButtonsInTheGroup(void)
 {
-    wxLogTrace(wxTRACE_COCOA,wxT("wxRadioButton"));
-    if(m_radioMaster && ([GetNSButton() state] == NSOnState))
+    if(m_radioMaster)
     {
         for(wxRadioButtonList::compatibility_iterator slaveNode =
                 m_radioMaster->m_radioSlaves.GetFirst();
@@ -156,6 +163,15 @@ void wxRadioButton::Cocoa_wxNSButtonAction(void)
                 radioButton->SetValue(false);
         }
     }
+}
+
+void wxRadioButton::Cocoa_wxNSButtonAction(void)
+{
+    wxLogTrace(wxTRACE_COCOA,wxT("wxRadioButton"));
+    if([GetNSButton() state] == NSOnState)
+    {
+        Cocoa_DeselectOtherButtonsInTheGroup();
+    }
     wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, GetId());
     InitCommandEvent(event); //    event.SetEventObject(this);
     event.SetInt(GetValue());