File tree Expand file tree Collapse file tree 1 file changed +2
-21
lines changed
korge/src/korlibs/korge/view Expand file tree Collapse file tree 1 file changed +2
-21
lines changed Original file line number Diff line number Diff line change @@ -177,24 +177,7 @@ open class Container(
177177 @KorgeUntested
178178 fun getChildByName (name : String ): View ? = __children .firstOrNull { it.name == name }
179179
180- fun removeChildAt (index : Int ): Boolean {
181- require(index >= 0 ) { " Index should be greater than or equal to 0" }
182- require(index < numChildren) { " Index should be less than numChildren: $numChildren , but was: $index " }
183-
184- val view = getChildAt(index)
185- view.parent = null
186- view.index = - 1
187-
188- __children .removeAt(index)
189-
190- for (i in index until numChildren) __children [i].index = i
191-
192- invalidateZIndexChildren()
193- invalidateContainer()
194- invalidateLocalBounds()
195-
196- return true
197- }
180+ fun removeChildAt (index : Int ) = removeChildAt(index, 1 ) == 1
198181
199182 fun removeChildAt (index : Int , count : Int ): Int {
200183 if (count <= 0 || index < 0 ) return 0
@@ -483,9 +466,7 @@ open class Container(
483466 * Remarks: If the parent of [view] is not this container, this function doesn't do anything.
484467 */
485468 fun removeChild (view : View ? ): Boolean {
486- require(view != null ) { " Removed view should not be null" }
487- require(view.parent == = this ) { " View $view is not a child of this container" }
488- check(getChildAt(view.index) == = view) { " View at index ${view.index} is not $view " }
469+ if (view?.parent != = this ) return false
489470
490471 return removeChildAt(view.index)
491472 }
You can’t perform that action at this time.
0 commit comments