mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-06 12:10:56 +08:00
[v3 Windows] Add WebviewWindow.Flash()
This commit is contained in:
parent
ecbb135949
commit
d6cfe4414d
@ -321,6 +321,15 @@ func main() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
stateMenu.Add("Flash Start").OnClick(func(ctx *application.Context) {
|
||||||
|
currentWindow(func(w *application.WebviewWindow) {
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
|
w.Flash(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
printMenu := menu.AddSubmenu("Print")
|
printMenu := menu.AddSubmenu("Print")
|
||||||
printMenu.Add("Print").OnClick(func(ctx *application.Context) {
|
printMenu.Add("Print").OnClick(func(ctx *application.Context) {
|
||||||
currentWindow(func(w *application.WebviewWindow) {
|
currentWindow(func(w *application.WebviewWindow) {
|
||||||
|
@ -70,6 +70,7 @@ type (
|
|||||||
setEnabled(enabled bool)
|
setEnabled(enabled bool)
|
||||||
absolutePosition() (int, int)
|
absolutePosition() (int, int)
|
||||||
setAbsolutePosition(x int, y int)
|
setAbsolutePosition(x int, y int)
|
||||||
|
flash(enabled bool)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -418,6 +419,16 @@ func (w *WebviewWindow) SetFullscreenButtonEnabled(enabled bool) *WebviewWindow
|
|||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flash flashes the window's taskbar button/icon. Windows only.
|
||||||
|
func (w *WebviewWindow) Flash(enabled bool) {
|
||||||
|
if w.impl == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
invokeSync(func() {
|
||||||
|
w.impl.flash(enabled)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// IsMinimised returns true if the window is minimised
|
// IsMinimised returns true if the window is minimised
|
||||||
func (w *WebviewWindow) IsMinimised() bool {
|
func (w *WebviewWindow) IsMinimised() bool {
|
||||||
if w.impl == nil {
|
if w.impl == nil {
|
||||||
|
@ -944,6 +944,10 @@ func (w *macosWebviewWindow) setTitle(title string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *macosWebviewWindow) flash(enabled bool) {
|
||||||
|
// Not supported on macOS
|
||||||
|
}
|
||||||
|
|
||||||
func (w *macosWebviewWindow) setSize(width, height int) {
|
func (w *macosWebviewWindow) setSize(width, height int) {
|
||||||
C.windowSetSize(w.nsWindow, C.int(width), C.int(height))
|
C.windowSetSize(w.nsWindow, C.int(width), C.int(height))
|
||||||
}
|
}
|
||||||
|
@ -179,6 +179,10 @@ func (w *linuxWebviewWindow) minimise() {
|
|||||||
windowMinimize(w.window)
|
windowMinimize(w.window)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *linuxWebviewWindow) flash(enabled bool) {
|
||||||
|
// Not supported on linux
|
||||||
|
}
|
||||||
|
|
||||||
func (w *linuxWebviewWindow) on(eventID uint) {
|
func (w *linuxWebviewWindow) on(eventID uint) {
|
||||||
// Don't think this is correct!
|
// Don't think this is correct!
|
||||||
// GTK Events are strings
|
// GTK Events are strings
|
||||||
|
@ -1464,6 +1464,10 @@ func (w *windowsWebviewWindow) setupChromium() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *windowsWebviewWindow) flash(enabled bool) {
|
||||||
|
w32.FlashWindow(w.hwnd, enabled)
|
||||||
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) navigationCompleted(sender *edge.ICoreWebView2, args *edge.ICoreWebView2NavigationCompletedEventArgs) {
|
func (w *windowsWebviewWindow) navigationCompleted(sender *edge.ICoreWebView2, args *edge.ICoreWebView2NavigationCompletedEventArgs) {
|
||||||
|
|
||||||
// Emit DomReady Event
|
// Emit DomReady Event
|
||||||
|
@ -915,6 +915,15 @@ const (
|
|||||||
SS_ELLIPSISMASK = 0x0000C000
|
SS_ELLIPSISMASK = 0x0000C000
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
FLASHW_STOP = 0 // Stop flashing. The system restores the window to its original state.
|
||||||
|
FLASHW_CAPTION = 1 // Flash the window caption.
|
||||||
|
FLASHW_TRAY = 2 // Flash the taskbar button.
|
||||||
|
FLASHW_ALL = 3 // Flash both the window caption and taskbar button. This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags.
|
||||||
|
FLASHW_TIMER = 4 // Flash continuously, until the FLASHW_STOP flag is set.
|
||||||
|
FLASHW_TIMERNOFG = 12 // Flash continuously until the window comes to the foreground.
|
||||||
|
)
|
||||||
|
|
||||||
// Edit styles
|
// Edit styles
|
||||||
const (
|
const (
|
||||||
ES_LEFT = 0x0000
|
ES_LEFT = 0x0000
|
||||||
|
@ -1133,3 +1133,11 @@ type SCROLLINFO struct {
|
|||||||
NPos int32
|
NPos int32
|
||||||
NTrackPos int32
|
NTrackPos int32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FLASHWINFO struct {
|
||||||
|
CbSize uint32
|
||||||
|
Hwnd HWND
|
||||||
|
DwFlags DWORD
|
||||||
|
UCount uint32
|
||||||
|
DwTimeout DWORD
|
||||||
|
}
|
||||||
|
@ -166,6 +166,8 @@ var (
|
|||||||
procGetScrollInfo = moduser32.NewProc("GetScrollInfo")
|
procGetScrollInfo = moduser32.NewProc("GetScrollInfo")
|
||||||
procSetScrollInfo = moduser32.NewProc("SetScrollInfo")
|
procSetScrollInfo = moduser32.NewProc("SetScrollInfo")
|
||||||
|
|
||||||
|
procFlashWindowEx = moduser32.NewProc("FlashWindowEx")
|
||||||
|
|
||||||
mainThread HANDLE
|
mainThread HANDLE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -234,3 +234,15 @@ func RegisterWindow(name string, proc WindowProc) (HINSTANCE, error) {
|
|||||||
|
|
||||||
return applicationInstance, nil
|
return applicationInstance, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FlashWindow(hwnd HWND, enabled bool) {
|
||||||
|
var flashInfo FLASHWINFO
|
||||||
|
flashInfo.CbSize = uint32(unsafe.Sizeof(flashInfo))
|
||||||
|
flashInfo.Hwnd = hwnd
|
||||||
|
if enabled {
|
||||||
|
flashInfo.DwFlags = FLASHW_ALL | FLASHW_TIMERNOFG
|
||||||
|
} else {
|
||||||
|
flashInfo.DwFlags = FLASHW_STOP
|
||||||
|
}
|
||||||
|
_, _, _ = procFlashWindowEx.Call(uintptr(unsafe.Pointer(&flashInfo)))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user