mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
[v3 windows] Add WebviewWindow.Print()
This commit is contained in:
@@ -294,6 +294,14 @@ func main() {
|
||||
app.InfoDialog().SetTitle(fmt.Sprintf("Screen %s", screen.ID)).SetMessage(msg).Show()
|
||||
})
|
||||
})
|
||||
|
||||
printMenu := menu.AddSubmenu("Print")
|
||||
printMenu.Add("Print").OnClick(func(ctx *application.Context) {
|
||||
currentWindow(func(w *application.WebviewWindow) {
|
||||
_ = w.Print()
|
||||
})
|
||||
})
|
||||
|
||||
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
|
||||
Mac: application.MacWindow{
|
||||
DisableShadow: true,
|
||||
|
||||
@@ -65,6 +65,7 @@ type (
|
||||
nativeWindowHandle() uintptr
|
||||
startDrag() error
|
||||
startResize(border string) error
|
||||
print() error
|
||||
}
|
||||
)
|
||||
|
||||
@@ -889,3 +890,10 @@ func (w *WebviewWindow) startDrag() error {
|
||||
}
|
||||
return invokeSyncWithError(w.impl.startDrag)
|
||||
}
|
||||
|
||||
func (w *WebviewWindow) Print() error {
|
||||
if w.impl == nil {
|
||||
return nil
|
||||
}
|
||||
return invokeSyncWithError(w.impl.print)
|
||||
}
|
||||
|
||||
@@ -62,6 +62,11 @@ type windowsWebviewWindow struct {
|
||||
resizeBorderHeight int32
|
||||
}
|
||||
|
||||
func (w *windowsWebviewWindow) print() error {
|
||||
w.execJS("window.print();")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *windowsWebviewWindow) startResize(border string) error {
|
||||
if !w32.ReleaseCapture() {
|
||||
return fmt.Errorf("unable to release mouse capture")
|
||||
|
||||
Reference in New Issue
Block a user