Skip to content

Commit

Permalink
fix menu item refreshing
Browse files Browse the repository at this point in the history
Before the removal of background colors, the refresh
on a menu item for updating the background color
was not really necessary because the menu refresh
already triggered the repaint of the menu (sub)tree.

With the background being normal canvas objects,
two errors in the refresh of the items revealed
which were hard to tackle:
- the previously active item was refreshed _before_
  it was deactivated
  -> the background color did not change
- the newly active item was not refreshed at all
  -> the background color did not change

This led to weird behavior where the items changed
there background to active when becoming inactive
and then never again.
  • Loading branch information
toaster committed Jan 16, 2021
1 parent 2b7e1a8 commit 557f0b6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion widget/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ func (m *Menu) CreateRenderer() fyne.WidgetRenderer {
// DeactivateChild deactivates the active menu item and hides its submenu if any.
func (m *Menu) DeactivateChild() {
if m.activeItem != nil {
defer m.activeItem.Refresh()
if c := m.activeItem.Child(); c != nil {
c.Hide()
}
m.activeItem.Refresh()
m.activeItem = nil
}
}
Expand Down Expand Up @@ -223,6 +223,7 @@ func (m *Menu) activateItem(item *menuItem) {

m.DeactivateChild()
m.activeItem = item
m.activeItem.Refresh()
m.Refresh()
}

Expand Down

0 comments on commit 557f0b6

Please sign in to comment.