From 5ff61545b3f44f9b9878a8eeebebc6db8bfefe68 Mon Sep 17 00:00:00 2001 From: Leslie Leigh Date: Tue, 6 Aug 2019 16:32:46 +0800 Subject: [PATCH] fix eventManager (#5103) --- cocos/scene-graph/base-node.ts | 2 +- cocos/scene-graph/node-event-processor.ts | 12 ++++++++++++ cocos/scene-graph/node.ts | 11 +++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cocos/scene-graph/base-node.ts b/cocos/scene-graph/base-node.ts index 481a99b240..46b2d76cf9 100644 --- a/cocos/scene-graph/base-node.ts +++ b/cocos/scene-graph/base-node.ts @@ -1171,7 +1171,7 @@ export class BaseNode extends CCObject implements IBaseNode { } } - protected _onPostActivated () { + protected _onPostActivated (active:boolean) { return; } diff --git a/cocos/scene-graph/node-event-processor.ts b/cocos/scene-graph/node-event-processor.ts index 8712fa50b5..5c50441199 100644 --- a/cocos/scene-graph/node-event-processor.ts +++ b/cocos/scene-graph/node-event-processor.ts @@ -348,6 +348,18 @@ export class NodeEventProcessor { this._node = node; } + public reattach (): void { + if (this.touchListener) { + var mask = this.touchListener.mask = _searchMaskInParent(this._node); + if (this.mouseListener) { + this.mouseListener.mask = mask; + } + } + else if (this.mouseListener) { + this.mouseListener.mask = _searchMaskInParent(this._node); + } + } + public destroy (): void{ if (_currentHovered === this._node) { _currentHovered = null; diff --git a/cocos/scene-graph/node.ts b/cocos/scene-graph/node.ts index 9f222eb655..8361741fdc 100644 --- a/cocos/scene-graph/node.ts +++ b/cocos/scene-graph/node.ts @@ -974,6 +974,17 @@ export class Node extends BaseNode implements INode { eventManager.resumeTarget(this, recursive); } + public _onPostActivated (active) { + if (active) { + eventManager.resumeTarget(this); + this.eventProcessor.reattach(); + } + else { + // deactivate + eventManager.pauseTarget(this); + } + } + public _onPreDestroy () { this._eventProcessor.destroy(); super._onPreDestroy();