diff --git a/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt b/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt index b8d9e45..c73bfa2 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/ClickGui.kt @@ -11,7 +11,9 @@ object ClickGui: SnowyScreen() { val clickBoxes get() = components.filterIsInstance() inline fun boxContext(args: ClickBox.() -> Unit) = clickBoxes.forEach(args) - private inline fun buttonsContext(args: ColoredElement.() -> Unit) = boxContext { buttons.forEach(args) } + private inline fun buttonsContext(args: ColoredElement.() -> Unit) = boxContext { buttons.forEach { + if (it.y > y + height) it.args() + } } override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { buttonsContext { this.mouseClicked(d, e, i) }; return false } override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { buttonsContext { this.mouseReleased(d, e, i) }; return false } override fun mouseScrolled(d: Double, e: Double, f: Double): Boolean { boxContext { scroll(d, e, f) }; return false }