[v3 windows] Add WebviewWindow.Print()

This commit is contained in:
Lea Anthony
2023-06-18 17:13:07 +10:00
parent 50387948df
commit ed27558011
3 changed files with 21 additions and 0 deletions
+8
View File
@@ -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,
+8
View File
@@ -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")