cefsharp / cefsharp/CefSharp

Wpf.HwndHost - Notify WPF when Browser has focus

Open
#5,038 0 comments 0 reactions 0 assignees View on GitHub
wpf.hwndhost
Dominant language
C#
Stars
10.3k
Forks
2.9k
Avg merge
5d 22h
Merged PRs (30d)
4

Description

Directly clicking the mouse in the browser and CEF will recieve focus, we need to let WPF know that our HWND host has focus in this scenario.

We need to set the Logical focus, not the actual focus.
Something like the following might work.
```c#
var focusScope = FocusManager.GetFocusScope(this);
if (FocusManager.GetFocusedElement(focusScope) != this)
{
FocusManager.SetFocusedElement(focusScope, this);
}
```

https://referencesource.microsoft.com/#PresentationCore/Core/CSharp/System/Windows/UIElement.cs,2647

When the browser directly gets focus `IFocusHandler.OnGotFocus` should be called.

Follow up to cefsharp/CefSharp.Wpf.HwndHost#5

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.