From 58f13046c0eab2a7293260b3acb21b5df5c1a586 Mon Sep 17 00:00:00 2001 From: FSaurenbach Date: Fri, 16 Jan 2026 20:44:45 +0100 Subject: [PATCH] korge: view: Implement addTo mutable list function Similar to https://github.com/korlibs/korge/blob/7485aae1ba8cb9d0b7ecc2853861f07cc5ff4204/korge/src/korlibs/korge/view/Container.kt#L554 Not sure if this belongs here, I find it very useful tho --- korge/src/korlibs/korge/view/View.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/korge/src/korlibs/korge/view/View.kt b/korge/src/korlibs/korge/view/View.kt index b58fbc297..da908c739 100644 --- a/korge/src/korlibs/korge/view/View.kt +++ b/korge/src/korlibs/korge/view/View.kt @@ -1568,6 +1568,11 @@ fun T.onNextFrame(block: T.(views: Views) -> Unit): CloseableCancella return closeable } +/** Add an arbitrary view to a mutable list. */ +fun T.addTo(parent: MutableList): T { + parent += this + return this +} // @TODO: Replace width, height with SizeInt fun T.onStageResized(firstTrigger: Boolean = true, block: Views.(width: Int, height: Int) -> Unit): T = this.apply {