Skip to content

Commit 3408ecb

Browse files
authored
Fix keyboard focus behavior. (#36)
Fixes #32.
1 parent 0ff61f8 commit 3408ecb

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

internal/w32/w32.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package w32
22

33
import (
4-
"golang.org/x/sys/windows"
54
"syscall"
65
"unicode/utf16"
76
"unsafe"
7+
8+
"golang.org/x/sys/windows"
89
)
910

1011
var (
@@ -38,6 +39,8 @@ var (
3839
User32SetWindowLongPtrW = user32.NewProc("SetWindowLongPtrW")
3940
User32AdjustWindowRect = user32.NewProc("AdjustWindowRect")
4041
User32SetWindowPos = user32.NewProc("SetWindowPos")
42+
User32IsDialogMessage = user32.NewProc("IsDialogMessage")
43+
User32GetAncestor = user32.NewProc("GetAncestor")
4144
)
4245

4346
const (
@@ -68,6 +71,12 @@ const (
6871
WMApp = 0x8000
6972
)
7073

74+
const (
75+
GAParent = 1
76+
GARoot = 2
77+
GARootOwner = 3
78+
)
79+
7180
const (
7281
GWLStyle = -16
7382
)

webview.go

+5
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ func (w *webview) Run() {
298298
} else if msg.Message == w32.WMQuit {
299299
return
300300
}
301+
r, _, _ := w32.User32GetAncestor.Call(uintptr(msg.Hwnd), w32.GARoot)
302+
r, _, _ = w32.User32IsDialogMessage.Call(r, uintptr(unsafe.Pointer(&msg)))
303+
if r != 0 {
304+
continue
305+
}
301306
_, _, _ = w32.User32TranslateMessage.Call(uintptr(unsafe.Pointer(&msg)))
302307
_, _, _ = w32.User32DispatchMessageW.Call(uintptr(unsafe.Pointer(&msg)))
303308
}

0 commit comments

Comments
 (0)