Search code examples
gofyne

Button with colored background


I am using fyne. I am working on a game (with buttons obviously). I would like to know if there is a way to change button's background? I know there is button with image instead of text, but I would only like to change background color of button.


Solution

  • The Fyne widget APIs are based on meaning rather than graphics, which makes two potential answers. You can mark a button as high importance (Button.Importance = widget.HighImportance) which will show as a primary colour.

    If your application wishes to control colour then the way you do it is to place a background rectangle under the button, which will show through (e.g. as container.NewMax(canvas.NewRectangle(bgColor), button)).