Change not to dispatch event when add radio buttons

This commit is contained in:
Neo Kim 2015-07-08 18:25:40 +09:00
parent db182b2e50
commit da85b16292
2 changed files with 9 additions and 3 deletions

View File

@ -194,7 +194,7 @@ void RadioButtonGroup::addRadioButton(RadioButton* radioButton)
if(!_allowedNoSelection && _selectedRadioButton == nullptr) if(!_allowedNoSelection && _selectedRadioButton == nullptr)
{ {
setSelectedButton(radioButton); setSelectedButtonWithoutEventCallback(radioButton);
} }
} }
} }
@ -219,7 +219,7 @@ void RadioButtonGroup::removeRadioButton(RadioButton* radioButton)
if(!_allowedNoSelection && _selectedRadioButton == nullptr && !_radioButtons.empty()) if(!_allowedNoSelection && _selectedRadioButton == nullptr && !_radioButtons.empty())
{ {
setSelectedButton(0); setSelectedButtonWithoutEventCallback(0);
} }
} }
} }
@ -261,6 +261,12 @@ void RadioButtonGroup::setSelectedButton(int index)
} }
void RadioButtonGroup::setSelectedButton(RadioButton* radioButton) void RadioButtonGroup::setSelectedButton(RadioButton* radioButton)
{
setSelectedButtonWithoutEventCallback(radioButton);
onChangedRadioButtonSelect(_selectedRadioButton);
}
void RadioButtonGroup::setSelectedButtonWithoutEventCallback(RadioButton* radioButton)
{ {
if(!_allowedNoSelection && radioButton == nullptr) if(!_allowedNoSelection && radioButton == nullptr)
{ {
@ -282,7 +288,6 @@ void RadioButtonGroup::setSelectedButton(RadioButton* radioButton)
{ {
_selectedRadioButton->setSelected(true); _selectedRadioButton->setSelected(true);
} }
onChangedRadioButtonSelect(_selectedRadioButton);
} }
std::string RadioButtonGroup::getDescription() const std::string RadioButtonGroup::getDescription() const

View File

@ -258,6 +258,7 @@ protected:
void onChangedRadioButtonSelect(RadioButton* radioButton); void onChangedRadioButtonSelect(RadioButton* radioButton);
void deselect(); void deselect();
void setSelectedButtonWithoutEventCallback(RadioButton* radioButton);
Vector<RadioButton*> _radioButtons; Vector<RadioButton*> _radioButtons;
ccRadioButtonGroupCallback _radioButtonGroupEventCallback; ccRadioButtonGroupCallback _radioButtonGroupEventCallback;