Implement the behaviour of Type.TOGGLE in ClickButton.kt
This commit is contained in:
parent
f85ed7e605
commit
b3c7fb1325
|
@ -37,12 +37,20 @@ class ClickButton(
|
|||
private fun lightUp() { opacity += lightningFactor }
|
||||
private fun lightDown() { opacity -= lightningFactor }
|
||||
override fun mouseClicked(d: Double, e: Double, i: Int): Boolean {
|
||||
wasWithinBounds = withinBounds(d, e).also { if (it) lightUp() }
|
||||
wasWithinBounds = withinBounds(d, e).also {
|
||||
if (it) {
|
||||
if (!toggled) lightUp() else lightDown()
|
||||
if ((kind == Type.TOGGLE)) {
|
||||
if (toggled) execAction()
|
||||
toggled = !toggled
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun mouseReleased(d: Double, e: Double, i: Int): Boolean {
|
||||
if (wasWithinBounds) {
|
||||
if (wasWithinBounds && (kind != Type.TOGGLE)) {
|
||||
lightDown()
|
||||
execAction()
|
||||
}; return false
|
||||
|
|
Loading…
Reference in New Issue