Flutter Engine
key_event_handler.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_KEY_EVENT_HANDLER_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_KEY_EVENT_HANDLER_H_
7 
8 #include <memory>
9 #include <string>
10 
11 #include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/basic_message_channel.h"
12 #include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/binary_messenger.h"
13 #include "flutter/shell/platform/windows/keyboard_hook_handler.h"
14 #include "flutter/shell/platform/windows/public/flutter_windows.h"
15 #include "rapidjson/document.h"
16 
17 namespace flutter {
18 
19 class FlutterWindowsView;
20 
21 // Implements a KeyboardHookHandler
22 //
23 // Handles key events and forwards them to the Flutter engine.
24 class KeyEventHandler : public KeyboardHookHandler {
25  public:
26  explicit KeyEventHandler(flutter::BinaryMessenger* messenger);
27 
28  virtual ~KeyEventHandler();
29 
30  // |KeyboardHookHandler|
31  void KeyboardHook(FlutterWindowsView* window,
32  int key,
33  int scancode,
34  int action,
35  char32_t character) override;
36 
37  // |KeyboardHookHandler|
38  void TextHook(FlutterWindowsView* window,
39  const std::u16string& text) override;
40 
41  private:
42  // The Flutter system channel for key event messages.
43  std::unique_ptr<flutter::BasicMessageChannel<rapidjson::Document>> channel_;
44 };
45 
46 } // namespace flutter
47 
48 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_KEY_EVENT_HANDLER_H_
SemanticsAction action
void KeyboardHook(GLFWwindow *window, int key, int scancode, int action, int mods) override
KeyEventHandler(flutter::BinaryMessenger *messenger)
void TextHook(FlutterWindowsView *window, const std::u16string &text) override