Skip to content

Instantly share code, notes, and snippets.

@janeoa
Last active June 27, 2021 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janeoa/178fa3e408121de32dc83ee91ed954f1 to your computer and use it in GitHub Desktop.
Save janeoa/178fa3e408121de32dc83ee91ed954f1 to your computer and use it in GitHub Desktop.
Tappable Circle does not appear but is tappable
package main
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
fatih "github.com/fatih/color"
)
type TapLabel struct {
*canvas.Circle
OnTapped func() `json:"-"`
}
func (mc *TapLabel) Tapped(*fyne.PointEvent) {
if mc.OnTapped != nil {
mc.OnTapped()
}
}
func newTabCircle(color color.Color, tapped func()) *TapLabel {
return &TapLabel{
canvas.NewCircle(color),
tapped,
}
}
func main() {
myApp := app.New()
myWindow := myApp.NewWindow("Tappable circle")
myWindow.Resize(fyne.NewSize(600, 600))
myWindow.SetContent(newTabCircle(color.White, send))
myWindow.ShowAndRun()
}
func send() {
fatih.Cyan("this\n")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment