Skip to content

Commit

Permalink
Fixes #243. Logical focus !== keyboard focus, and since we changed th…
Browse files Browse the repository at this point in the history
…e logic for #242 we must also change this (since without it, the caret is seen in multiple WebViews simultaneously. :)
  • Loading branch information
perlun committed Feb 5, 2014
1 parent 55f76a8 commit 55ecf77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions CefSharp.Wpf/WebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ namespace CefSharp

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

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

void WebView::OnGotFocus(RoutedEventArgs^ e)
void WebView::OnGotKeyboardFocus(Object^ sender, KeyboardFocusChangedEventArgs^ e)
{
CefRefPtr<CefBrowser> browser;
if (TryGetCefBrowser(browser))
{
browser->SendFocusEvent(true);
}

ContentControl::OnGotFocus(e);
}

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

HidePopup();

ContentControl::OnLostFocus(e);
}

void WebView::OnPreviewKeyDown(KeyEventArgs^ e)
Expand Down
4 changes: 2 additions & 2 deletions CefSharp.Wpf/WebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ namespace CefSharp

void OnLoaded(Object^ sender, RoutedEventArgs^ e);
void OnUnloaded(Object^ sender, RoutedEventArgs^ e);
void OnGotKeyboardFocus(Object^ sender, KeyboardFocusChangedEventArgs^ e);
void OnLostKeyboardFocus(Object^ sender, KeyboardFocusChangedEventArgs^ e);
void OnPopupMouseMove(Object^ sender, MouseEventArgs^ e);
void OnPopupMouseWheel(Object^ sender,MouseWheelEventArgs^ e);
void OnPopupMouseDown(Object^ sender,MouseButtonEventArgs^ e);
Expand All @@ -99,8 +101,6 @@ namespace CefSharp

protected:
virtual Size ArrangeOverride(Size size) override;
virtual void OnGotFocus(RoutedEventArgs^ e) override;
virtual void OnLostFocus(RoutedEventArgs^ e) override;
virtual void OnPreviewKeyDown(KeyEventArgs^ e) override;
virtual void OnPreviewKeyUp(KeyEventArgs^ e) override;
virtual void OnPreviewTextInput(TextCompositionEventArgs^ e) override;
Expand Down

0 comments on commit 55ecf77

Please sign in to comment.