Skip to content

Commit

Permalink
fix: Fix the issue where TAB cannot cycle through focus elements.
Browse files Browse the repository at this point in the history
Signed-off-by: SmileSky <[email protected]>
  • Loading branch information
mzdk100 committed Jan 14, 2025
1 parent 26abf63 commit f46ef07
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/element-focus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'wry': 'patch:enhance'
---

Allow the use of TAB to cycle through focus elements in an HTML document.
10 changes: 10 additions & 0 deletions src/webview2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ impl InnerWebView {
wparam: WPARAM,
lparam: LPARAM,
) -> LRESULT {
if msg == WM_SETFOCUS {
// Fix https://github.com/DioxusLabs/dioxus/issues/2900
// Get the first child window of the window
let child = GetWindow(hwnd, GW_CHILD).unwrap_or_default();
if child != HWND::default() {
// Set focus to the child window(WebView document)
let _ = SetFocus(child);
}
}

DefWindowProcW(hwnd, msg, wparam, lparam)
}

Expand Down

0 comments on commit f46ef07

Please sign in to comment.