Add receivers to ClickGui.kt too

This commit is contained in:
Username404-59 2021-05-06 21:11:41 +02:00
parent f4a16a10d2
commit f8fbf1eb09
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
1 changed files with 5 additions and 5 deletions

View File

@ -19,11 +19,11 @@ object ClickGui: SnowyScreen() {
override val components = mutableSetOf<Element>() override val components = mutableSetOf<Element>()
internal fun addComps(vararg toAdd: Element) = components.addAll(toAdd) internal fun addComps(vararg toAdd: Element) = components.addAll(toAdd)
inline fun boxContext(args: (ClickBox) -> Unit) = components.filterIsInstance<ClickBox>().forEach(args) inline fun boxContext(args: ClickBox.() -> Unit) = components.filterIsInstance<ClickBox>().forEach(args)
private inline fun buttonsContext(args: (ClickButton) -> Unit) = boxContext { it.buttons.values.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 { it.mouseClicked(d, e, i) }; return false } 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 { it.mouseReleased(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 { it.scroll(d, e, f) }; 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 { override fun mouseDragged(d: Double, e: Double, i: Int, f: Double, g: Double): Boolean {
if (i == 0) { if (i == 0) {
components.forEach { components.forEach {