fix eventManager (#5103)

This commit is contained in:
Leslie Leigh
2019-08-06 16:32:46 +08:00
committed by pandamicro
parent 75aa882aca
commit 5ff61545b3
3 changed files with 24 additions and 1 deletions
+1 -1
View File
@@ -1171,7 +1171,7 @@ export class BaseNode extends CCObject implements IBaseNode {
}
}
protected _onPostActivated () {
protected _onPostActivated (active:boolean) {
return;
}
+12
View File
@@ -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;
+11
View File
@@ -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();