Skip to content

Commit 55ecf77

Browse files
committed
Fixes cefsharp#243. Logical focus !== keyboard focus, and since we changed the logic for cefsharp#242 we must also change this (since without it, the caret is seen in multiple WebViews simultaneously. :)
1 parent 55f76a8 commit 55ecf77

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

CefSharp.Wpf/WebView.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ namespace CefSharp
4545

4646
this->Loaded += gcnew RoutedEventHandler(this, &WebView::OnLoaded);
4747
this->Unloaded += gcnew RoutedEventHandler(this, &WebView::OnUnloaded);
48+
this->GotKeyboardFocus += gcnew KeyboardFocusChangedEventHandler(this, &WebView::OnGotKeyboardFocus);
49+
this->LostKeyboardFocus += gcnew KeyboardFocusChangedEventHandler(this, &WebView::OnLostKeyboardFocus);
4850
}
4951

5052
bool WebView::TryGetCefBrowser(CefRefPtr<CefBrowser>& browser)
@@ -284,18 +286,16 @@ namespace CefSharp
284286
return ContentControl::ArrangeOverride(size);
285287
}
286288

287-
void WebView::OnGotFocus(RoutedEventArgs^ e)
289+
void WebView::OnGotKeyboardFocus(Object^ sender, KeyboardFocusChangedEventArgs^ e)
288290
{
289291
CefRefPtr<CefBrowser> browser;
290292
if (TryGetCefBrowser(browser))
291293
{
292294
browser->SendFocusEvent(true);
293295
}
294-
295-
ContentControl::OnGotFocus(e);
296296
}
297297

298-
void WebView::OnLostFocus(RoutedEventArgs^ e)
298+
void WebView::OnLostKeyboardFocus(Object^ sender, KeyboardFocusChangedEventArgs^ e)
299299
{
300300
CefRefPtr<CefBrowser> browser;
301301
if (TryGetCefBrowser(browser))
@@ -304,8 +304,6 @@ namespace CefSharp
304304
}
305305

306306
HidePopup();
307-
308-
ContentControl::OnLostFocus(e);
309307
}
310308

311309
void WebView::OnPreviewKeyDown(KeyEventArgs^ e)

CefSharp.Wpf/WebView.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ namespace CefSharp
8282

8383
void OnLoaded(Object^ sender, RoutedEventArgs^ e);
8484
void OnUnloaded(Object^ sender, RoutedEventArgs^ e);
85+
void OnGotKeyboardFocus(Object^ sender, KeyboardFocusChangedEventArgs^ e);
86+
void OnLostKeyboardFocus(Object^ sender, KeyboardFocusChangedEventArgs^ e);
8587
void OnPopupMouseMove(Object^ sender, MouseEventArgs^ e);
8688
void OnPopupMouseWheel(Object^ sender,MouseWheelEventArgs^ e);
8789
void OnPopupMouseDown(Object^ sender,MouseButtonEventArgs^ e);
@@ -99,8 +101,6 @@ namespace CefSharp
99101

100102
protected:
101103
virtual Size ArrangeOverride(Size size) override;
102-
virtual void OnGotFocus(RoutedEventArgs^ e) override;
103-
virtual void OnLostFocus(RoutedEventArgs^ e) override;
104104
virtual void OnPreviewKeyDown(KeyEventArgs^ e) override;
105105
virtual void OnPreviewKeyUp(KeyEventArgs^ e) override;
106106
virtual void OnPreviewTextInput(TextCompositionEventArgs^ e) override;

0 commit comments

Comments
 (0)