fixed error when active/disactive richtext node (#2846)

This commit is contained in:
yinkaile
2018-06-11 17:53:15 +08:00
committed by pandamicro
parent b57ab464f2
commit cb5b8dbc47
+11 -1
View File
@@ -291,13 +291,14 @@ let RichText = cc.Class({
this._addEventListeners();
}
this._updateRichText();
this._activateChildren(true);
},
onDisable () {
if (this.handleTouchEvent) {
this._removeEventListeners();
}
this._resetState();
this._activateChildren(false);
},
start () {
@@ -407,6 +408,15 @@ let RichText = cc.Class({
this._layoutDirty = true;
},
_activateChildren (active) {
for (let i = this.node.children.length - 1; i >= 0; i--) {
let child = this.node.children[i];
if (child.name === RichTextChildName) {
child.active = active;
}
}
},
_addLabelSegment (stringToken, styleIndex) {
let labelSegment;
if (this._labelSegmentsCache.length === 0) {