| Flutter Windows Embedder |

keyboard_handler_base.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_KEYBOARD_HANDLER_BASE_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_KEYBOARD_HANDLER_BASE_H_
7
8 #include <string>
9
10 namespace flutter {
11
12 // Interface for classes that handles keyboard input events.
13 //
14 // Keyboard handlers are added to |FlutterWindowsView| in a chain.
15 // When a key event arrives, |KeyboardHook| is called on each handler
16 // until the first one that returns true. Then the proper text hooks
17 // are called on each handler.
18 class KeyboardHandlerBase {
19 public:
20 using KeyEventCallback = std::function<void(bool)>;
21
22 virtual ~KeyboardHandlerBase() = default;
23
24 // A function for hooking into keyboard input.
25 virtual void KeyboardHook(int key,
26 int scancode,
27 int action,
28 char32_t character,
29 bool extended,
30 bool was_down,
31 KeyEventCallback callback) = 0;
32
33 // If needed, synthesize modifier keys events by comparing the
34 // given modifiers state to the known pressing state..
35 virtual void SyncModifiersIfNeeded(int modifiers_state) = 0;
36
37 // Returns the keyboard pressed state.
38 //
39 // Returns the keyboard pressed state. The map contains one entry per
40 // pressed keys, mapping from the logical key to the physical key.
41 virtual std::map<uint64_t, uint64_t> GetPressedState() = 0;
42 };
43
44 } // namespace flutter
45
46 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_KEYBOARD_HANDLER_BASE_H_
flutter::KeyboardHandlerBase
Definition: keyboard_handler_base.h:18
flutter::KeyboardHandlerBase::GetPressedState
virtual std::map< uint64_t, uint64_t > GetPressedState()=0
flutter::KeyboardHandlerBase::SyncModifiersIfNeeded
virtual void SyncModifiersIfNeeded(int modifiers_state)=0
flutter::KeyboardHandlerBase::~KeyboardHandlerBase
virtual ~KeyboardHandlerBase()=default
flutter::KeyboardHandlerBase::KeyEventCallback
std::function< void(bool)> KeyEventCallback
Definition: keyboard_handler_base.h:20
flutter::KeyboardHandlerBase::KeyboardHook
virtual void KeyboardHook(int key, int scancode, int action, char32_t character, bool extended, bool was_down, KeyEventCallback callback)=0
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:52
extended
bool extended
Definition: keyboard_key_handler_unittests.cc:118
key
int key
Definition: keyboard_key_handler_unittests.cc:114
character
char32_t character
Definition: keyboard_key_handler_unittests.cc:117
action
int action
Definition: keyboard_key_handler_unittests.cc:116
scancode
int scancode
Definition: keyboard_key_handler_unittests.cc:115
was_down
bool was_down
Definition: keyboard_key_handler_unittests.cc:119
flutter
Definition: accessibility_bridge_windows.cc:11