Fix the behaviour of Type.CLICK
This commit is contained in:
		
							parent
							
								
									69625d3aef
								
							
						
					
					
						commit
						8a49f24249
					
				| @ -59,8 +59,10 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) { | |||||||
|     private fun lightDown() { opacity -= ButtonInfo.lightningFactor } |     private fun lightDown() { opacity -= ButtonInfo.lightningFactor } | ||||||
|     override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { |     override fun mouseClicked(d: Double, e: Double, i: Int): Boolean { | ||||||
|         wasWithinBounds = withinBounds(d, e).also { |         wasWithinBounds = withinBounds(d, e).also { | ||||||
|             if (it && (info.kind == Type.TOGGLE)) { |             if (it) { | ||||||
|                 toggled = !toggled |                 if (info.kind == Type.TOGGLE) { | ||||||
|  |                     toggled = !toggled | ||||||
|  |                 } else if (info.kind == Type.CLICK) lightUp() | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         return false |         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 { |     override fun mouseReleased(d: Double, e: Double, i: Int): Boolean { | ||||||
|         if (wasWithinBounds && (info.kind == Type.CLICK)) { |         if (wasWithinBounds && (info.kind == Type.CLICK)) { | ||||||
|             toggled = true |             execAction() | ||||||
|  |             lightDown() | ||||||
|         }; return false |         }; return false | ||||||
|     } |     } | ||||||
|     override fun render(poseStack: PoseStack?) { |     override fun render(poseStack: PoseStack?) { | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ annotation class ButtonInfo( | |||||||
|         internal var lightningFactor: Float = 0.33F |         internal var lightningFactor: Float = 0.33F | ||||||
|         enum class Type { |         enum class Type { | ||||||
|             TOGGLE, |             TOGGLE, | ||||||
|             CLICK // TODO Fix the CLICK behaviour |             CLICK | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| }; enum class Category(val translationKey: String, val categoryColor: Colors) { | }; enum class Category(val translationKey: String, val categoryColor: Colors) { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user