Skip to content

Commit

Permalink
replace NodeEventType.SIBLING_ORDER_CHANGED with NodeEventType.CHILDR…
Browse files Browse the repository at this point in the history
…EN_ORDER_CHANGED (#16246)

* replace NodeEventType.SIBLING_ORDER_CHANGED with NodeEventType.CHILDREN_ORDER_CHANGED
  • Loading branch information
minggo authored Sep 13, 2023
1 parent 0e53dde commit ea8ca11
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cocos/input/types/event-enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
Expand Down
12 changes: 10 additions & 2 deletions cocos/scene-graph/node-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions cocos/scene-graph/node.jsb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion cocos/scene-graph/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cocos/ui/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down

0 comments on commit ea8ca11

Please sign in to comment.