Fixed what Keys managedCefBrowserAdapter send

Problem: Not all input-keys was sent to handled in Javascript, especially keycombinations like Strg + X, Strg + V and so on wasn't handled. Now, with the fix, this is no longer a problem. Also the keys, special handled in the original version, are no longer needed and so i removed them.
This commit is contained in:
geste
2014-11-10 11:33:40 +01:00
parent a0d1aa5d66
commit 520ff1aebd
+5 -25
View File
@@ -837,40 +837,20 @@ namespace CefSharp.Wpf
// For some reason, not all kinds of keypresses triggers the appropriate WM_ messages handled by our SourceHook, so
// we have to handle these extra keys here. Hooking the Tab key like this makes the tab focusing in essence work like
// KeyboardNavigation.TabNavigation="Cycle"; you will never be able to Tab out of the web browser control.
var modifiers = GetModifiers(e);
if (KeysToSendtoBrowser.Contains(e.Key))
if (KeysToSendtoBrowser.Contains(e.Key) || modifiers > 0)
{
var message = (int)(e.IsDown ? WM.KEYDOWN : WM.KEYUP);
var virtualKey = KeyInterop.VirtualKeyFromKey(e.Key);
var modifiers = GetModifiers(e);
managedCefBrowserAdapter.SendKeyEvent(message, virtualKey, modifiers);
e.Handled = true;
}
if (e.IsDown && e.KeyboardDevice.Modifiers == ModifierKeys.Control)
{
switch (e.Key)
if (KeysToSendtoBrowser.Contains(e.Key) || (modifiers.HasFlag(CefEventFlags.ShiftDown) && modifiers.HasFlag(CefEventFlags.ControlDown)))
{
case Key.X:
managedCefBrowserAdapter.Cut();
break;
case Key.C:
managedCefBrowserAdapter.Copy();
break;
case Key.V:
managedCefBrowserAdapter.Paste();
break;
case Key.A:
managedCefBrowserAdapter.SelectAll();
break;
case Key.Z:
managedCefBrowserAdapter.Undo();
break;
case Key.Y:
managedCefBrowserAdapter.Redo();
break;
e.Handled = true;
}
}
}