Skip to content

Commit

Permalink
Move optimisation for button hover to tap as well
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Dec 15, 2022
1 parent 43d3a98 commit 326ecbb
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions widget/button.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,7 @@ func (b *Button) MinSize() fyne.Size {
func (b *Button) MouseIn(*desktop.MouseEvent) {
b.hovered = true

if b.background != nil {
b.applyButtonTheme()
b.background.Refresh()
}
b.applyButtonTheme()
}

// MouseMoved is called when a desktop pointer hovers over the widget
Expand All @@ -175,10 +172,7 @@ func (b *Button) MouseMoved(*desktop.MouseEvent) {
func (b *Button) MouseOut() {
b.hovered = false

if b.background != nil {
b.applyButtonTheme()
b.background.Refresh()
}
b.applyButtonTheme()
}

// SetIcon updates the icon on a label - pass nil to hide an icon
Expand All @@ -202,7 +196,7 @@ func (b *Button) Tapped(*fyne.PointEvent) {
}

b.tapAnimation()
b.Refresh()
b.applyButtonTheme()

if b.OnTapped != nil {
b.OnTapped()
Expand All @@ -221,7 +215,12 @@ func (b *Button) TypedKey(ev *fyne.KeyEvent) {
}

func (b *Button) applyButtonTheme() {
if b.background == nil {
return
}

b.background.FillColor = b.buttonColor()
b.background.Refresh()
}

func (b *Button) buttonColor() color.Color {
Expand Down

0 comments on commit 326ecbb

Please sign in to comment.