// ------------------------------------------------------------------------
protected:
virtual void Cocoa_wxNSButtonAction(void);
+private:
+ void Cocoa_DeselectOtherButtonsInTheGroup(void);
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
void wxRadioButton::SetValue(bool value)
{
if(value)
+ {
[GetNSButton() setState: NSOnState];
+ Cocoa_DeselectOtherButtonsInTheGroup();
+ }
else
[GetNSButton() setState: NSOffState];
}
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();
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());