Fix the buttons being clickable when hidden in ClickGui.kt

This commit is contained in:
Username404-59 2021-06-30 17:15:55 +02:00
parent 530ecb36cb
commit 03ecdd9e2c
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 3 additions and 1 deletions

View File

@ -11,7 +11,9 @@ object ClickGui: SnowyScreen() {
val clickBoxes get() = components.filterIsInstance<ClickBox>()
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 }