go_dreamfactory/cmd/v2/ui/tip.go
2022-10-08 11:03:35 +08:00

41 lines
789 B
Go

package ui
import (
"image/color"
"time"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/widget"
)
// 显示Tip
func showTip(content string) {
drv := fyne.CurrentApp().Driver()
if drv, ok := drv.(desktop.Driver); ok {
w := drv.CreateSplashWindow()
w.SetContent(widget.NewLabelWithStyle(content, fyne.TextAlignCenter, fyne.TextStyle{}))
w.Show()
go func() {
time.Sleep(time.Millisecond * 1500)
w.Close()
}()
}
}
func showCanvasTip(content string) {
drv := fyne.CurrentApp().Driver()
if drv, ok := drv.(desktop.Driver); ok {
w := drv.CreateSplashWindow()
w.SetContent(canvas.NewText(content, color.RGBA{255, 0, 0, 255}))
w.Show()
go func() {
time.Sleep(time.Millisecond * 1500)
w.Close()
}()
}
}