diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt index 4634cbf..400a82c 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt @@ -59,8 +59,10 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) { private fun lightDown() { opacity -= ButtonInfo.lightningFactor } override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { wasWithinBounds = withinBounds(d, e).also { - if (it && (info.kind == Type.TOGGLE)) { - toggled = !toggled + if (it) { + if (info.kind == Type.TOGGLE) { + toggled = !toggled + } else if (info.kind == Type.CLICK) lightUp() } } return false @@ -68,7 +70,8 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) { override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { if (wasWithinBounds && (info.kind == Type.CLICK)) { - toggled = true + execAction() + lightDown() }; return false } override fun render(poseStack: PoseStack?) { diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonInfo.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonInfo.kt index a938e7b..e0bca79 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonInfo.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonInfo.kt @@ -17,7 +17,7 @@ annotation class ButtonInfo( internal var lightningFactor: Float = 0.33F enum class Type { TOGGLE, - CLICK // TODO Fix the CLICK behaviour + CLICK } } }; enum class Category(val translationKey: String, val categoryColor: Colors) {