Skip to content

Commit

Permalink
Merge pull request fyne-io#5332 from andydotxyz/fix/5331
Browse files Browse the repository at this point in the history
Fix tapping of a check when its height > minHeight
  • Loading branch information
andydotxyz authored Dec 18, 2024
2 parents 0685580 + 9b66d57 commit 9d5a17c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion widget/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,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
}
Expand Down
14 changes: 14 additions & 0 deletions widget/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 9d5a17c

Please sign in to comment.