-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathKeyboardHandler.cs
More file actions
118 lines (114 loc) · 7.63 KB
/
KeyboardHandler.cs
File metadata and controls
118 lines (114 loc) · 7.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright © 2021 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.
namespace CefSharp.Handler
{
/// <summary>
/// Inherit from this class to handle events related to keyboard input.
/// </summary>
public class KeyboardHandler : IKeyboardHandler
{
/// <summary>
/// Called before a keyboard event is sent to the renderer.
/// Return true if the event was handled or false
/// otherwise. If the event will be handled in <see cref="OnKeyEvent"/> as a keyboard
/// shortcut set isKeyboardShortcut to true and return false.
/// </summary>
/// <param name="chromiumWebBrowser">the ChromiumWebBrowser control</param>
/// <param name="browser">The browser instance.</param>
/// <param name="type">Whether this was a key up/down/raw/etc...</param>
/// <param name="windowsKeyCode">
/// The Windows key code for the key event. This value is used by the DOM
/// specification. Sometimes it comes directly from the event (i.e. on
/// Windows) and sometimes it's determined using a mapping function. See
/// WebCore/platform/chromium/KeyboardCodes.h for the list of values.
/// </param>
/// <param name="nativeKeyCode">The native key code. On Windows this appears to be in the format of WM_KEYDOWN/WM_KEYUP/etc... lParam data.</param>
/// <param name="modifiers">What other modifier keys are currently down: Shift/Control/Alt/OS X Command/etc...</param>
/// <param name="isSystemKey">
/// Indicates whether the event is considered a "system key" event (see
/// http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for details).
/// </param>
/// <param name="isKeyboardShortcut">See the summary for an explanation of when to set this to true.</param>
/// <returns>Returns true if the event was handled or false otherwise.</returns>
bool IKeyboardHandler.OnPreKeyEvent(IWebBrowser chromiumWebBrowser, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
{
return OnPreKeyEvent(chromiumWebBrowser, browser, type, windowsKeyCode, nativeKeyCode, modifiers, isSystemKey, ref isKeyboardShortcut);
}
/// <summary>
/// Called before a keyboard event is sent to the renderer.
/// Return true if the event was handled or false
/// otherwise. If the event will be handled in <see cref="OnKeyEvent"/> as a keyboard
/// shortcut set isKeyboardShortcut to true and return false.
/// </summary>
/// <param name="chromiumWebBrowser">the ChromiumWebBrowser control</param>
/// <param name="browser">The browser instance.</param>
/// <param name="type">Whether this was a key up/down/raw/etc...</param>
/// <param name="windowsKeyCode">
/// The Windows key code for the key event. This value is used by the DOM
/// specification. Sometimes it comes directly from the event (i.e. on
/// Windows) and sometimes it's determined using a mapping function. See
/// WebCore/platform/chromium/KeyboardCodes.h for the list of values.
/// </param>
/// <param name="nativeKeyCode">The native key code. On Windows this appears to be in the format of WM_KEYDOWN/WM_KEYUP/etc... lParam data.</param>
/// <param name="modifiers">What other modifier keys are currently down: Shift/Control/Alt/OS X Command/etc...</param>
/// <param name="isSystemKey">
/// Indicates whether the event is considered a "system key" event (see
/// http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for details).
/// </param>
/// <param name="isKeyboardShortcut">See the summary for an explanation of when to set this to true.</param>
/// <returns>Returns true if the event was handled or false otherwise.</returns>
protected virtual bool OnPreKeyEvent(IWebBrowser chromiumWebBrowser, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
{
return false;
}
/// <summary>
/// Called after the renderer and JavaScript in the page has had a chance to
/// handle the event. Return true if the keyboard event was handled or false otherwise.
/// </summary>
/// <param name="chromiumWebBrowser">the ChromiumWebBrowser control</param>
/// <param name="browser">The browser instance.</param>
/// <param name="type">Whether this was a key up/down/raw/etc...</param>
/// <param name="windowsKeyCode">
/// The Windows key code for the key event. This value is used by the DOM
/// specification. Sometimes it comes directly from the event (i.e. on
/// Windows) and sometimes it's determined using a mapping function. See
/// WebCore/platform/chromium/KeyboardCodes.h for the list of values.
/// </param>
/// <param name="nativeKeyCode">The native key code. On Windows this appears to be in the format of WM_KEYDOWN/WM_KEYUP/etc... lParam data.</param>
/// <param name="modifiers">What other modifier keys are currently down: Shift/Control/Alt/OS X Command/etc...</param>
/// <param name="isSystemKey">
/// Indicates whether the event is considered a "system key" event (see
/// http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for details).
/// </param>
/// <returns>Return true if the keyboard event was handled or false otherwise.</returns>
bool IKeyboardHandler.OnKeyEvent(IWebBrowser chromiumWebBrowser, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
{
return OnKeyEvent(chromiumWebBrowser, browser, type, windowsKeyCode, nativeKeyCode, modifiers, isSystemKey);
}
/// <summary>
/// Called after the renderer and JavaScript in the page has had a chance to
/// handle the event. Return true if the keyboard event was handled or false otherwise.
/// </summary>
/// <param name="chromiumWebBrowser">the ChromiumWebBrowser control</param>
/// <param name="browser">The browser instance.</param>
/// <param name="type">Whether this was a key up/down/raw/etc...</param>
/// <param name="windowsKeyCode">
/// The Windows key code for the key event. This value is used by the DOM
/// specification. Sometimes it comes directly from the event (i.e. on
/// Windows) and sometimes it's determined using a mapping function. See
/// WebCore/platform/chromium/KeyboardCodes.h for the list of values.
/// </param>
/// <param name="nativeKeyCode">The native key code. On Windows this appears to be in the format of WM_KEYDOWN/WM_KEYUP/etc... lParam data.</param>
/// <param name="modifiers">What other modifier keys are currently down: Shift/Control/Alt/OS X Command/etc...</param>
/// <param name="isSystemKey">
/// Indicates whether the event is considered a "system key" event (see
/// http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for details).
/// </param>
/// <returns>Return true if the keyboard event was handled or false otherwise.</returns>
protected virtual bool OnKeyEvent(IWebBrowser chromiumWebBrowser, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
{
return false;
}
}
}