disable toggle group when group is disabled

This commit is contained in:
zilongshanren
2017-04-17 13:34:51 +08:00
parent 792570ef52
commit f158c294b8
+8 -8
View File
@@ -108,7 +108,7 @@ var Toggle = cc.Class({
if(!CC_EDITOR) {
this._registerToggleEvent();
}
if(this.toggleGroup) {
if(this.toggleGroup && this.toggleGroup.enabled) {
this.toggleGroup.addToggle(this);
}
},
@@ -118,14 +118,14 @@ var Toggle = cc.Class({
if(!CC_EDITOR) {
this._unregisterToggleEvent();
}
if(this.toggleGroup) {
if(this.toggleGroup && this.toggleGroup.enabled) {
this.toggleGroup.removeToggle(this);
}
},
_updateCheckMark: function () {
if(this.checkMark) {
this.checkMark.enabled = !!this.isChecked;
this.checkMark.node.active = !!this.isChecked;
}
},
@@ -151,7 +151,7 @@ var Toggle = cc.Class({
},
toggle: function (event) {
if(this.toggleGroup && this.isChecked) {
if(this.toggleGroup && this.toggleGroup.enabled && this.isChecked) {
if(!this.toggleGroup.allowSwitchOff) {
return;
}
@@ -161,7 +161,7 @@ var Toggle = cc.Class({
this._updateCheckMark();
if(this.toggleGroup) {
if(this.toggleGroup && this.toggleGroup.enabled) {
this.toggleGroup.updateToggles(this);
}
@@ -181,7 +181,7 @@ var Toggle = cc.Class({
* @method check
*/
check: function () {
if(this.toggleGroup && this.isChecked) {
if(this.toggleGroup && this.toggleGroup.enabled && this.isChecked) {
if(!this.toggleGroup.allowSwitchOff) {
return;
}
@@ -189,7 +189,7 @@ var Toggle = cc.Class({
this.isChecked = true;
if(this.toggleGroup) {
if(this.toggleGroup && this.toggleGroup.enabled) {
this.toggleGroup.updateToggles(this);
}
@@ -202,7 +202,7 @@ var Toggle = cc.Class({
* @method uncheck
*/
uncheck: function () {
if(this.toggleGroup && this.isChecked) {
if(this.toggleGroup && this.toggleGroup.enabled && this.isChecked) {
if(!this.toggleGroup.allowSwitchOff) {
return;
}