mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-17 01:19:29 +08:00
[windows] ignore mouse events
This commit is contained in:
parent
e661052c89
commit
3422c40e19
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@ -100,6 +101,21 @@ func main() {
|
|||||||
}).Show()
|
}).Show()
|
||||||
windowCounter++
|
windowCounter++
|
||||||
})
|
})
|
||||||
|
myMenu.Add("New WebviewWindow (ignores mouse events").
|
||||||
|
SetAccelerator("CmdOrCtrl+F").
|
||||||
|
OnClick(func(ctx *application.Context) {
|
||||||
|
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
|
||||||
|
HTML: "<div style='width: 100%; height: 95%; border: 3px solid red; background-color: \"0000\";'></div>",
|
||||||
|
X: rand.Intn(1000),
|
||||||
|
Y: rand.Intn(800),
|
||||||
|
IgnoreMouseEvents: true,
|
||||||
|
BackgroundType: application.BackgroundTypeTransparent,
|
||||||
|
Mac: application.MacWindow{
|
||||||
|
InvisibleTitleBarHeight: 50,
|
||||||
|
},
|
||||||
|
}).Show()
|
||||||
|
windowCounter++
|
||||||
|
})
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
myMenu.Add("New WebviewWindow (MacTitleBarHiddenInset)").
|
myMenu.Add("New WebviewWindow (MacTitleBarHiddenInset)").
|
||||||
OnClick(func(ctx *application.Context) {
|
OnClick(func(ctx *application.Context) {
|
||||||
@ -384,6 +400,16 @@ func main() {
|
|||||||
_ = w.Print()
|
_ = w.Print()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
printMenu.Add("Capture PNG").OnClick(func(ctx *application.Context) {
|
||||||
|
currentWindow(func(w *application.WebviewWindow) {
|
||||||
|
img, err := w.CapturePNG()
|
||||||
|
if err != nil {
|
||||||
|
application.ErrorDialog().SetTitle("Error").SetMessage(err.Error()).Show()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
os.WriteFile("capture.png", img, 0644)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
|
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
|
||||||
BackgroundColour: application.NewRGB(33, 37, 41),
|
BackgroundColour: application.NewRGB(33, 37, 41),
|
||||||
|
@ -115,6 +115,9 @@ type WebviewWindowOptions struct {
|
|||||||
|
|
||||||
// KeyBindings is a map of key bindings to functions
|
// KeyBindings is a map of key bindings to functions
|
||||||
KeyBindings map[string]func(window *WebviewWindow)
|
KeyBindings map[string]func(window *WebviewWindow)
|
||||||
|
|
||||||
|
// IgnoreMouseEvents will ignore mouse events in the window
|
||||||
|
IgnoreMouseEvents bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var WebviewWindowDefaults = &WebviewWindowOptions{
|
var WebviewWindowDefaults = &WebviewWindowOptions{
|
||||||
|
@ -179,6 +179,9 @@ func (w *windowsWebviewWindow) run() {
|
|||||||
exStyle = w32.WS_EX_CONTROLPARENT
|
exStyle = w32.WS_EX_CONTROLPARENT
|
||||||
if options.BackgroundType != BackgroundTypeSolid {
|
if options.BackgroundType != BackgroundTypeSolid {
|
||||||
exStyle |= w32.WS_EX_NOREDIRECTIONBITMAP
|
exStyle |= w32.WS_EX_NOREDIRECTIONBITMAP
|
||||||
|
if w.parent.options.IgnoreMouseEvents {
|
||||||
|
exStyle |= w32.WS_EX_TRANSPARENT | w32.WS_EX_LAYERED
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if options.AlwaysOnTop {
|
if options.AlwaysOnTop {
|
||||||
exStyle |= w32.WS_EX_TOPMOST
|
exStyle |= w32.WS_EX_TOPMOST
|
||||||
|
Loading…
Reference in New Issue
Block a user