Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
text_input_plugin.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_GLFW_TEXT_INPUT_PLUGIN_H_
6#define FLUTTER_SHELL_PLATFORM_GLFW_TEXT_INPUT_PLUGIN_H_
7
8#include <map>
9#include <memory>
10
11#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"
12#include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h"
13#include "flutter/shell/platform/common/text_input_model.h"
14#include "flutter/shell/platform/glfw/keyboard_hook_handler.h"
15#include "flutter/shell/platform/glfw/public/flutter_glfw.h"
16
17#include "rapidjson/document.h"
18
19namespace flutter {
20
21// Implements a text input plugin.
22//
23// Specifically handles window events within GLFW.
25 public:
26 explicit TextInputPlugin(flutter::BinaryMessenger* messenger);
27
29
30 // |KeyboardHookHandler|
31 void KeyboardHook(GLFWwindow* window,
32 int key,
33 int scancode,
34 int action,
35 int mods) override;
36
37 // |KeyboardHookHandler|
38 void CharHook(GLFWwindow* window, unsigned int code_point) override;
39
40 private:
41 // Sends the current state of the given model to the Flutter engine.
42 void SendStateUpdate(const TextInputModel& model);
43
44 // Sends an action triggered by the Enter key to the Flutter engine.
45 void EnterPressed(TextInputModel* model);
46
47 // Called when a method is called on |channel_|;
48 void HandleMethodCall(
51
52 // The MethodChannel used for communication with the Flutter engine.
53 std::unique_ptr<flutter::MethodChannel<rapidjson::Document>> channel_;
54
55 // The active client id.
56 int client_id_ = 0;
57
58 // The active model. nullptr if not set.
59 std::unique_ptr<TextInputModel> active_model_;
60
61 // Keyboard type of the client. See available options:
62 // https://api.flutter.dev/flutter/services/TextInputType-class.html
63 std::string input_type_;
64
65 // An action requested by the user on the input client. See available options:
66 // https://api.flutter.dev/flutter/services/TextInputAction-class.html
67 std::string input_action_;
68};
69
70} // namespace flutter
71
72#endif // FLUTTER_SHELL_PLATFORM_GLFW_TEXT_INPUT_PLUGIN_H_
void KeyboardHook(GLFWwindow *window, int key, int scancode, int action, int mods) override
void CharHook(GLFWwindow *window, unsigned int code_point) override
GLFWwindow * window
Definition main.cc:45
G_BEGIN_DECLS G_MODULE_EXPORT FlMethodCall * method_call
GAsyncResult * result