From edf89db6fc28931ca59f6c9acfd0a561d68145c7 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 19 Aug 2025 15:32:17 +0200 Subject: add discard2 icon and button to trigger the free action --- go/ui/button.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'go/ui/button.go') diff --git a/go/ui/button.go b/go/ui/button.go index 9afa8c05..6e8fd8b7 100644 --- a/go/ui/button.go +++ b/go/ui/button.go @@ -83,3 +83,18 @@ func (b *SimpleButton) UpdateLabel(label string) { b.ForceRedraw() } } + +type ImageButton struct { + WidgetBase + img *ebiten.Image +} + +func NewImageButton(x, y int, img *ebiten.Image, onClick func(b *ImageButton)) *ImageButton { + bounds := img.Bounds() + sb := &ImageButton{NewWidgetBase(x, y, bounds.Dx(), bounds.Dy()), img} + sb.EventHandlersMap["click"] = func(int, int) { onClick(sb) } + sb.renderImpl = func() *ebiten.Image { + return sb.img + } + return sb +} -- cgit v1.2.3