Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace NodeEventType.SIBLING_ORDER_CHANGED with NodeEventType.CHILDREN_ORDER_CHANGED #16246

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not since 3.3. Only 3.8.2 has this API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SystemEventType. SIBLING_ORDER_CHANGED is deprecated since v3.3.

*/
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