Files
cefsharp/CefSharp.WinForms.Example/ChromiumContainerControl.cs
T
amaitland 1d2fb9531f WinForms Example - Add ChromiumContainerControl to host docked DevTools
Required for arrow/tab key presses to be forwarded correctly to DevTools
Only required when CefSettings.MultiThreadedMessageLoop = false
2019-09-10 19:41:21 +10:00

40 lines
1.2 KiB
C#

// Copyright © 2019 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System.Windows.Forms;
namespace CefSharp.WinForms.Example
{
public class DevToolsContainerControl : Control
{
protected override bool IsInputKey(Keys keyData)
{
//This code block is only called/required when CEF is running in the
//same message loop as the WinForms UI (CefSettings.MultiThreadedMessageLoop = false)
//Without this code, arrows and tab won't be processed
switch (keyData)
{
case Keys.Right:
case Keys.Left:
case Keys.Up:
case Keys.Down:
case Keys.Tab:
{
return true;
}
case Keys.Shift | Keys.Tab:
case Keys.Shift | Keys.Right:
case Keys.Shift | Keys.Left:
case Keys.Shift | Keys.Up:
case Keys.Shift | Keys.Down:
{
return true;
}
}
return base.IsInputKey(keyData);
}
}
}