From 5f3d9e8381d22c5be1bc18dc88b177590ef894e0 Mon Sep 17 00:00:00 2001 From: knoxHuang <821686174@qq.com> Date: Mon, 10 Jul 2017 15:06:58 +0800 Subject: [PATCH] fix CCRichText event for fireball/issues/5226 --- cocos2d/core/components/CCRichText.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cocos2d/core/components/CCRichText.js b/cocos2d/core/components/CCRichText.js index cf2bf9ccf3..bee31f63f0 100644 --- a/cocos2d/core/components/CCRichText.js +++ b/cocos2d/core/components/CCRichText.js @@ -213,12 +213,14 @@ var RichText = cc.Class({ VerticalAlign: VerticalAlign }, - __preload: function () { + onEnable: function () { this._super(); + this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this); + }, - if (!CC_EDITOR) { - this._registerEvents(); - } + onDisable: function () { + this._super(); + this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this); }, _createSgNode: function () { @@ -321,10 +323,6 @@ var RichText = cc.Class({ return cc.rectContainsPoint(myRect, point); }, - _registerEvents: function () { - this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this); - }, - _resetState: function () { var sgNode = this._sgNode; if(sgNode) {