Last active
June 27, 2021 00:35
-
-
Save janeoa/178fa3e408121de32dc83ee91ed954f1 to your computer and use it in GitHub Desktop.
Tappable Circle does not appear but is tappable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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