tauri-apps / wry

Cross-platform WebView library in Rust for Tauri.
Apache License 2.0
3.73k stars 284 forks source link

feat: add `WebView::focus_parent` method. #1385

Closed huacnlee closed 1 month ago

huacnlee commented 1 month ago

The blur method need in some case, for example the WebView is a child in window (The WebView is not full size in the Window). When we click the main area, we want the WebView to lose the focus handle.

I use this for add Wry into GPUI, here is the bug fix:

https://github.com/huacnlee/gpui-component/pull/320

Before

https://github.com/user-attachments/assets/cc614334-47fe-4722-8745-aea783fbab4a

After

After called cx.blur on mouse click outside the WebView area.

On macOS, now the IME bug is gone.

https://github.com/user-attachments/assets/363bb016-229f-4766-84f7-6a4838e490bf

huacnlee commented 1 month ago

Windows as test passed.

https://github.com/user-attachments/assets/320c5c1c-cfac-4165-af8a-bc9708952460

github-actions[bot] commented 1 month ago

Package Changes Through b6a2ba6b91e341cc95258524f430506a0b278c07

There are 1 changes which include wry with patch

Planned Package Versions The following package releases are the planned based on the context of changes in this pull request. | package | current | next | |----|----|----| | wry | 0.46.0 | 0.46.1 |

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

huacnlee commented 1 month ago

I can rename it do focus_parent.

This should be provided a method from wry, because I can't get the parent view in outside.

amrbashir commented 1 month ago

I guess we can include it then.

amrbashir commented 1 month ago

WebkitGTK, Android (I don't find the API doc how to implement it, so keep is do nothing.)

Android can be documented as unsupported. As for webkit2gtk, try calling widget.parent_window() and then call focus on it.

huacnlee commented 1 month ago

Can I just keep Android unsupport? the reason is:

  1. I found that the focus method also not did supported in Android.
  2. I don't know how to test it, to make sure the change is correct.