Skip to content

Commit

Permalink
Merge branch 'CefSharp1' of github.com:shen6041/CefSharp into shen604…
Browse files Browse the repository at this point in the history
…1-CefSharp1, so we can work towards closing #211.
  • Loading branch information
perlun committed Jan 21, 2014
2 parents 3b076d1 + b121f93 commit c25d8ba
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
54 changes: 36 additions & 18 deletions CefSharp.Wpf/WebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,42 @@ namespace CefSharp

void WebView::OnPreviewKey(KeyEventArgs^ e)
{
CefRefPtr<CefBrowser> browser;
if (!TryGetCefBrowser(browser))
{
return;
}

if (e->Key == Key::Tab ||
e->Key >= Key::Left && e->Key <= Key::Down)
{
CefBrowser::KeyType type = e->IsDown ? KT_KEYDOWN : KT_KEYUP;
CefKeyInfo keyInfo;
keyInfo.key = KeyInterop::VirtualKeyFromKey(e->Key);
browser->SendKeyEvent(type, keyInfo, 0);

e->Handled = true;
}
}

CefRefPtr<CefBrowser> browser;
if (!TryGetCefBrowser(browser))
{
return;
}

if (e->Key == Key::Tab ||e->Key >= Key::Left && e->Key <= Key::Down)
{
CefBrowser::KeyType type = e->IsDown ? KT_KEYDOWN : KT_KEYUP;
CefKeyInfo keyInfo;
keyInfo.key = KeyInterop::VirtualKeyFromKey(e->Key);
browser->SendKeyEvent(type, keyInfo, 0);

e->Handled = true;
}
}

void WebView::OnPreviewTextInput(TextCompositionEventArgs^ e)
{
CefRefPtr<CefBrowser> browser;
if (!TryGetCefBrowser(browser))
{
return;
}

CefBrowser::KeyType type;
for (int i = 0;i<e->Text->Length;i++)
{
CefKeyInfo keyInfo;
keyInfo.key =(int)e->Text[i];
type = KT_CHAR;
browser->SendKeyEvent(type, keyInfo, 0);
}
e->Handled = true;
}

void WebView::OnMouseButton(MouseButtonEventArgs^ e)
{
CefRefPtr<CefBrowser> browser;
Expand Down
1 change: 1 addition & 0 deletions CefSharp.Wpf/WebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ namespace CefSharp
virtual void OnLostFocus(RoutedEventArgs^ e) override;
virtual void OnPreviewKeyDown(KeyEventArgs^ e) override;
virtual void OnPreviewKeyUp(KeyEventArgs^ e) override;
virtual void OnPreviewTextInput(TextCompositionEventArgs^ e) override;

virtual void OnMouseMove(MouseEventArgs^ e) override;
virtual void OnMouseWheel(MouseWheelEventArgs^ e) override;
Expand Down

0 comments on commit c25d8ba

Please sign in to comment.