Make wxRadioButton::SetValue(true) deselect all other wxRadioButton in its group if it is part of a group.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47568 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -56,6 +56,8 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
protected:
|
||||
virtual void Cocoa_wxNSButtonAction(void);
|
||||
private:
|
||||
void Cocoa_DeselectOtherButtonsInTheGroup(void);
|
||||
// ------------------------------------------------------------------------
|
||||
// Implementation
|
||||
// ------------------------------------------------------------------------
|
||||
|
@@ -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());
|
||||
|
Reference in New Issue
Block a user