Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggling toolbar icons does not refresh #1809

Closed
colinmo opened this issue Jan 15, 2021 · 1 comment
Closed

Toggling toolbar icons does not refresh #1809

colinmo opened this issue Jan 15, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@colinmo
Copy link

colinmo commented Jan 15, 2021

While using Append and Prepend you can add buttons to a Toolbar and it refreshes, if you change an existing ToolbarItem and try to refresh, it does not. This is because toolbar.resetObjects first checks to see if the number of toolbar items has changed before doing any refreshing. Obviously if changing the image for an icon (for example toggling bookmark on/ off for a list) the number of items in the toolbar does not change.

To Reproduce:

  1. Create a toolbar via widget.NewToolbar with any number of ToolbarItems with icons
  2. Display the toolbar in a window/canvas/layout.
  3. Programmatically change any of the ToolbarItems
  4. Refresh the window/canvas/layout/toolbar
  5. The icon does not change

Alter the code in toolbar.go to remove the changed-items-count test and the button changes.

Example code:

func toggleBookmark() {
	var index = isBookmarkedAt(dt.Format("2006-01-02"))
	if index == -1 {
		appPreferences.Bookmarks = append(appPreferences.Bookmarks, dt.Format("2006-01-02"))
		toolB.Items[8] = widget.NewToolbarAction(theme.ContentRemoveIcon(), toggleBookmark)
	} else {
		var mep = appPreferences.Bookmarks
		appPreferences.Bookmarks = append(mep[:index], mep[index+1:]...)
		toolB.Items[8] = widget.NewToolbarAction(theme.ContentAddIcon(), toggleBookmark)
	}
	sort.Strings(appPreferences.Bookmarks)
	bookmarksList.Refresh()
}

Device (please complete the following information):

  • OS: Tested on Windows and MacOS
  • Version: Windows 10, MacOS Catalina
  • Go version: go1.13.5
  • Fyne version: 1.4.3
@colinmo colinmo added the bug Something isn't working label Jan 15, 2021
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Jan 16, 2021
@andydotxyz andydotxyz self-assigned this Jan 16, 2021
@andydotxyz
Copy link
Member

On develop for testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants