diff --git a/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt b/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt index 54ac909..182bdfa 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt @@ -19,11 +19,11 @@ object ClickGui: SnowyScreen() { override val components = mutableSetOf() internal fun addComps(vararg toAdd: Element) = components.addAll(toAdd) - inline fun boxContext(args: (ClickBox) -> Unit) = components.filterIsInstance().forEach(args) - private inline fun buttonsContext(args: (ClickButton) -> Unit) = boxContext { it.buttons.values.forEach(args) } - override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { buttonsContext { it.mouseClicked(d, e, i) }; return false } - override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { buttonsContext { it.mouseReleased(d, e, i) }; return false } - override fun mouseScrolled(d: Double, e: Double, f: Double): Boolean { boxContext { it.scroll(d, e, f) }; return false } + inline fun boxContext(args: ClickBox.() -> Unit) = components.filterIsInstance().forEach(args) + private inline fun buttonsContext(args: ClickButton.() -> Unit) = boxContext { buttons.values.forEach(args) } + override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { buttonsContext { mouseClicked(d, e, i) }; return false } + override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { buttonsContext { mouseReleased(d, e, i) }; return false } + override fun mouseScrolled(d: Double, e: Double, f: Double): Boolean { boxContext { scroll(d, e, f) }; return false } override fun mouseDragged(d: Double, e: Double, i: Int, f: Double, g: Double): Boolean { if (i == 0) { components.forEach {