MCPcopy Create free account
hub / github.com/esengine/esengine / setChildIndex

Method setChildIndex

packages/fairygui/src/core/GComponent.ts:250–268  ·  view source on GitHub ↗

* Set child index * 设置子对象索引

(child: GObject, index: number)

Source from the content-addressed store, hash-verified

248 * 设置子对象索引
249 */
250 public setChildIndex(child: GObject, index: number): void {
251 const oldIndex = this._children.indexOf(child);
252 if (oldIndex === -1) {
253 throw new Error('Not a child of this container');
254 }
255
256 if (child.sortingOrder !== 0) {
257 return;
258 }
259
260 const count = this._children.length;
261 if (this._sortingChildCount > 0) {
262 if (index > count - this._sortingChildCount - 1) {
263 index = count - this._sortingChildCount - 1;
264 }
265 }
266
267 this.moveChild(child, oldIndex, index);
268 }
269
270 /**
271 * Set child index before another child

Callers 6

addChildAtMethod · 0.95
swapChildrenAtMethod · 0.95
addChildAtFunction · 0.80
moveChildMethod · 0.80
bringToFrontMethod · 0.80

Calls 1

moveChildMethod · 0.95

Tested by

no test coverage detected