Skip to content

Commit

Permalink
simplify MouseMoved
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Jan 8, 2024
1 parent d84159b commit c630423
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions widget/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,11 @@ func (c *Check) MouseMoved(me *desktop.MouseEvent) {
}

oldHovered := c.hovered
if c.minSize.Width == 0 && c.minSize.Height == 0 {
c.hovered = true
} else if me.Position.X <= c.minSize.Width && me.Position.Y <= c.minSize.Height {
c.hovered = true
} else {
// mouse outside the active area of the widget
c.hovered = false
}

// only hovered if cached minSize has not been initialized (test code)
// or the pointer is within the "active" area of the widget (its minSize)
c.hovered = c.minSize.IsZero() ||
(me.Position.X <= c.minSize.Width && me.Position.Y <= c.minSize.Height)

if oldHovered != c.hovered {
c.Refresh()
Expand All @@ -131,7 +128,7 @@ func (c *Check) Tapped(pe *fyne.PointEvent) {
if c.Disabled() {
return
}
if c.minSize.Height > 0 && c.minSize.Width > 0 &&
if !c.minSize.IsZero() &&
(pe.Position.X > c.minSize.Width || pe.Position.Y > c.minSize.Height) {
// tapped outside the active area of the widget
return
Expand Down

0 comments on commit c630423

Please sign in to comment.