mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
replace NodeEventType.SIBLING_ORDER_CHANGED with NodeEventType.CHILDREN_ORDER_CHANGED (#16246)
* replace NodeEventType.SIBLING_ORDER_CHANGED with NodeEventType.CHILDREN_ORDER_CHANGED
This commit is contained in:
@@ -265,7 +265,7 @@ export enum SystemEventType {
|
||||
* @en The event type for node's sibling order changed.
|
||||
* @zh 当节点在兄弟节点中的顺序发生变化时触发的事件。
|
||||
*
|
||||
* @deprecated since v3.3, please use Node.EventType.SIBLING_ORDER_CHANGED instead
|
||||
* @deprecated since v3.3, please use Node.EventType.CHILDREN_ORDER_CHANGED instead
|
||||
*/
|
||||
SIBLING_ORDER_CHANGED = 'sibling-order-changed',
|
||||
}
|
||||
|
||||
@@ -245,11 +245,19 @@ export enum NodeEventType {
|
||||
LAYER_CHANGED = 'layer-changed',
|
||||
|
||||
/**
|
||||
* @en The event type for node's sibling order changed.
|
||||
* @zh 当节点在兄弟节点中的顺序发生变化时触发的事件。
|
||||
* @en This event indicates that the order of child nodes has been changed.
|
||||
* @zh 该事件表示子节点的排序发生了改变。
|
||||
* @deprecated since v3.8.2 @en Please use `CHILDREN_ORDER_CHANGED`. @zh 请使用 `CHILDREN_ORDER_CHANGED`。
|
||||
*/
|
||||
SIBLING_ORDER_CHANGED = 'sibling-order-changed',
|
||||
|
||||
/**
|
||||
* @en This event indicates that the order of child nodes has been changed.
|
||||
* @zh 该事件表示子节点的排序发生了改变。
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
||||
CHILDREN_ORDER_CHANGED = 'sibling-order-changed',
|
||||
|
||||
/**
|
||||
* @en
|
||||
* Note: This event is only emitted from the top most node whose active value did changed,
|
||||
|
||||
@@ -280,7 +280,7 @@ nodeProto.on = function (type, callback, target, useCapture: any = false) {
|
||||
this._registeredNodeEventTypeMask |= REGISTERED_EVENT_MASK_LAYER_CHANGED;
|
||||
}
|
||||
break;
|
||||
case NodeEventType.SIBLING_ORDER_CHANGED:
|
||||
case NodeEventType.CHILDREN_ORDER_CHANGED:
|
||||
if (!(this._registeredNodeEventTypeMask & REGISTERED_EVENT_MASK_SIBLING_ORDER_CHANGED)) {
|
||||
this._registerOnSiblingOrderChanged();
|
||||
this._registeredNodeEventTypeMask |= REGISTERED_EVENT_MASK_SIBLING_ORDER_CHANGED;
|
||||
@@ -492,7 +492,7 @@ nodeProto.destroyAllChildren = function destroyAllChildren() {
|
||||
};
|
||||
|
||||
nodeProto._onSiblingOrderChanged = function () {
|
||||
this.emit(NodeEventType.SIBLING_ORDER_CHANGED);
|
||||
this.emit(NodeEventType.CHILDREN_ORDER_CHANGED);
|
||||
};
|
||||
|
||||
nodeProto._onActivateNode = function (shouldActiveNow) {
|
||||
|
||||
@@ -1309,7 +1309,7 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable {
|
||||
this._children[i]._siblingIndex = i;
|
||||
}
|
||||
|
||||
this.emit(NodeEventType.SIBLING_ORDER_CHANGED);
|
||||
this.emit(NodeEventType.CHILDREN_ORDER_CHANGED);
|
||||
}
|
||||
|
||||
protected _instantiate (cloned, isSyncedNode): any {
|
||||
|
||||
+2
-2
@@ -736,7 +736,7 @@ export class Layout extends Component {
|
||||
this.node.on(NodeEventType.ANCHOR_CHANGED, this._doLayoutDirty, this);
|
||||
this.node.on(NodeEventType.CHILD_ADDED, this._childAdded, this);
|
||||
this.node.on(NodeEventType.CHILD_REMOVED, this._childRemoved, this);
|
||||
this.node.on(NodeEventType.SIBLING_ORDER_CHANGED, this._childrenChanged, this);
|
||||
this.node.on(NodeEventType.CHILDREN_ORDER_CHANGED, this._childrenChanged, this);
|
||||
this.node.on('childrenSiblingOrderChanged', this.updateLayout, this);
|
||||
this._addChildrenEventListeners();
|
||||
}
|
||||
@@ -747,7 +747,7 @@ export class Layout extends Component {
|
||||
this.node.off(NodeEventType.ANCHOR_CHANGED, this._doLayoutDirty, this);
|
||||
this.node.off(NodeEventType.CHILD_ADDED, this._childAdded, this);
|
||||
this.node.off(NodeEventType.CHILD_REMOVED, this._childRemoved, this);
|
||||
this.node.off(NodeEventType.SIBLING_ORDER_CHANGED, this._childrenChanged, this);
|
||||
this.node.off(NodeEventType.CHILDREN_ORDER_CHANGED, this._childrenChanged, this);
|
||||
this.node.off('childrenSiblingOrderChanged', this.updateLayout, this);
|
||||
this._removeChildrenEventListeners();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user