* Set child index * 设置子对象索引
(child: GObject, index: number)
| 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 |
no test coverage detected