mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
fix mask event through bug (#8293)
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
import { ccclass, help, executionOrder, menu, tooltip, displayOrder, type, visible, override, serializable, range, slide } from 'cc.decorator';
|
||||
import { InstanceMaterialType, Renderable2D } from '../framework/renderable-2d';
|
||||
import { clamp, Color, Mat4, Vec2, Vec3 } from '../../core/math';
|
||||
import { warnID } from '../../core/platform';
|
||||
import { SystemEventType, warnID } from '../../core/platform';
|
||||
import { Batcher2D } from '../renderer/batcher-2d';
|
||||
import { ccenum } from '../../core/value-types/enum';
|
||||
import { Graphics } from './graphics';
|
||||
@@ -373,6 +373,8 @@ export class Mask extends Renderable2D {
|
||||
super.onEnable();
|
||||
this._updateGraphics();
|
||||
this._broadcastToNode(this.node);
|
||||
this.node.on(SystemEventType.CHILD_ADDED, this._addChild, this);
|
||||
this.node.on(SystemEventType.CHILD_REMOVED, this._removeChild, this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,6 +389,8 @@ export class Mask extends Renderable2D {
|
||||
public onDisable () {
|
||||
super.onDisable();
|
||||
this._disableGraphics();
|
||||
this.node.off(SystemEventType.CHILD_ADDED, this._addChild, this);
|
||||
this.node.off(SystemEventType.CHILD_REMOVED, this._removeChild, this);
|
||||
}
|
||||
|
||||
public onDestroy () {
|
||||
@@ -617,6 +621,17 @@ export class Mask extends Renderable2D {
|
||||
this._broadcastToNode(children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// add node.eventProcessor.listener.mask when add to mask
|
||||
protected _addChild (child) {
|
||||
this._broadcastToNode(child);
|
||||
child.walk(() => { child.eventProcessor.reattach(); });
|
||||
}
|
||||
|
||||
// clean node.eventProcessor.listener.mask when remove from mask
|
||||
protected _removeChild (node) {
|
||||
node.walk(() => { node.eventProcessor.registerComponentHitList(null); node.eventProcessor.reattach(); });
|
||||
}
|
||||
}
|
||||
|
||||
legacyCC.Mask = Mask;
|
||||
|
||||
@@ -360,7 +360,6 @@ export class NodeEventProcessor {
|
||||
}
|
||||
|
||||
public reattach (): void {
|
||||
if (!this._comp) return;
|
||||
if (this.touchListener) {
|
||||
const mask = this.touchListener.mask = _searchComponentsInParent(this._node as Node, this._comp);
|
||||
if (this.mouseListener) {
|
||||
|
||||
@@ -73,7 +73,7 @@ enum EventType {
|
||||
|
||||
@ccclass('cc.EditBox')
|
||||
@help('i18n:cc.EditBox')
|
||||
@executionOrder(100)
|
||||
@executionOrder(110)
|
||||
@menu('UI/EditBox')
|
||||
@requireComponent(UITransform)
|
||||
@executeInEditMode
|
||||
|
||||
Reference in New Issue
Block a user