From 9b66d57c3ec5b4a99049a22697039deab266c5fe Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Wed, 18 Dec 2024 15:20:33 +0000 Subject: [PATCH] Fix tapping of a check when its height > minHeight Fixes #5331 --- widget/check.go | 5 ++++- widget/check_test.go | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/widget/check.go b/widget/check.go index ef57bd4d21..9e5dde9fd3 100644 --- a/widget/check.go +++ b/widget/check.go @@ -141,8 +141,11 @@ func (c *Check) Tapped(pe *fyne.PointEvent) { if c.Disabled() { return } + + minHeight := c.minSize.Height + minY := (c.Size().Height - minHeight) / 2 if !c.minSize.IsZero() && - (pe.Position.X > c.minSize.Width || pe.Position.Y > c.minSize.Height) { + (pe.Position.X > c.minSize.Width || pe.Position.Y < minY || pe.Position.Y > minY+minHeight) { // tapped outside the active area of the widget return } diff --git a/widget/check_test.go b/widget/check_test.go index b10df751eb..374a362a5a 100644 --- a/widget/check_test.go +++ b/widget/check_test.go @@ -118,5 +118,19 @@ func TestCheck_Tapped(t *testing.T) { test.Tap(check) assert.False(t, check.Checked) assert.False(t, check.Partial) +} + +func TestCheck_Resize(t *testing.T) { + check := &widget.Check{Text: "test"} + check.Resize(fyne.NewSize(300, 200)) + min := check.MinSize() // set up min cache + assert.Less(t, min.Height, check.Size().Height) + test.TapAt(check, fyne.NewPos(10, 100)) + assert.True(t, check.Checked) + test.TapAt(check, fyne.NewPos(10, 100)) + assert.False(t, check.Checked) + + test.TapAt(check, fyne.NewPos(10, 10)) + assert.False(t, check.Checked) }