5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-06 22:11:02 +08:00

[v3 Breaking Change] Add NativeWindowHandle method to WebviewWindow.

This commit is contained in:
Lea Anthony 2023-04-30 10:17:03 +10:00 committed by Misite Bao
parent 728e2019d8
commit 17204bebd0
2 changed files with 13 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package application package application
import ( import (
"errors"
"fmt" "fmt"
"github.com/samber/lo" "github.com/samber/lo"
"sync" "sync"
@ -59,6 +60,7 @@ type (
getScreen() (*Screen, error) getScreen() (*Screen, error)
setFrameless(bool) setFrameless(bool)
openContextMenu(menu *Menu, data *ContextMenuData) openContextMenu(menu *Menu, data *ContextMenuData)
nativeWindowHandle() uintptr
} }
) )
@ -693,3 +695,10 @@ func (w *WebviewWindow) RegisterContextMenu(name string, menu *Menu) {
defer w.contextMenusLock.Unlock() defer w.contextMenusLock.Unlock()
w.contextMenus[name] = menu w.contextMenus[name] = menu
} }
func (w *WebviewWindow) NativeWindowHandle() (uintptr, error) {
if w.impl == nil {
return 0, errors.New("native handle unavailable as window is not running")
}
return w.impl.nativeWindowHandle(), nil
}

View File

@ -21,6 +21,10 @@ type windowsWebviewWindow struct {
hwnd w32.HWND hwnd w32.HWND
} }
func (w *windowsWebviewWindow) nativeWindowHandle() uintptr {
return w.hwnd
}
func (w *windowsWebviewWindow) setTitle(title string) { func (w *windowsWebviewWindow) setTitle(title string) {
//TODO implement me //TODO implement me
panic("implement me") panic("implement me")