From cb5b8dbc47fe59bd3b677363a705c44afd40e7d5 Mon Sep 17 00:00:00 2001 From: yinkaile <501251991@qq.com> Date: Mon, 11 Jun 2018 17:53:15 +0800 Subject: [PATCH] fixed error when active/disactive richtext node (#2846) --- cocos2d/core/components/CCRichText.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/components/CCRichText.js b/cocos2d/core/components/CCRichText.js index ca8795f35d..cbe55d07ce 100644 --- a/cocos2d/core/components/CCRichText.js +++ b/cocos2d/core/components/CCRichText.js @@ -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) {