| Flutter Windows Embedder |

Public Member Functions | Friends | List of all members
flutter::TextInputPlugin Class Reference

`#include <text_input_plugin.h>`

## Public Member Functions
| TextInputPlugin (flutter::BinaryMessenger *messenger, FlutterWindowsEngine *engine)
virtual | ~TextInputPlugin ()
virtual void | KeyboardHook (int key, int scancode, int action, char32_t character, bool extended, bool was_down)
virtual void | TextHook (const std::u16string &text)
virtual void | ComposeBeginHook ()
virtual void | ComposeCommitHook ()
virtual void | ComposeEndHook ()
virtual void | ComposeChangeHook (const std::u16string &text, int cursor_pos)

## Friends
class | TextInputPluginModifier

## Detailed Description

Definition at line 29 of file text_input_plugin.h.

## Constructor & Destructor Documentation

## ◆ TextInputPlugin()

flutter::TextInputPlugin::TextInputPlugin | ( | flutter::BinaryMessenger * | messenger,
|  | FlutterWindowsEngine * | engine
| ) |  |

Definition at line 108 of file text_input_plugin.cc.

110 : channel_(std::make_unique<flutter::MethodChannel<rapidjson::Document>>(
111 messenger,
112 kChannelName,
113 &flutter::JsonMethodCodec::GetInstance())),
114 engine_(engine),
115 active_model_(nullptr) {
116 channel_->SetMethodCallHandler(
117 [this](
118 const flutter::MethodCall<rapidjson::Document>& call,
119 std::unique_ptr<flutter::MethodResult<rapidjson::Document>> result) {
120 HandleMethodCall(call, std::move(result));
121 });
122 }
flutter::JsonMethodCodec::GetInstance
static const JsonMethodCodec & GetInstance()
Definition: json_method_codec.cc:36
flutter::MethodCall
Definition: method_call.h:18
flutter::MethodChannel
Definition: method_channel.h:34
flutter::MethodResult
Definition: method_result.h:17
kChannelName
static constexpr char kChannelName[]
Definition: text_input_plugin.cc:58

## ◆ ~TextInputPlugin()

flutter::TextInputPlugin::~TextInputPlugin | ( |  | ) |
| virtualdefault

## Member Function Documentation

## ◆ ComposeBeginHook()

void flutter::TextInputPlugin::ComposeBeginHook | ( |  | ) |
| virtual

Definition at line 126 of file text_input_plugin.cc.

126 {
127 if (active_model_ == nullptr) {
128 return;
129 }
130 active_model_->BeginComposing();
131 if (enable_delta_model) {
132 std::string text = active_model_->GetText();
133 TextRange selection = active_model_->selection();
134 TextEditingDelta delta = TextEditingDelta(text);
135 SendStateUpdateWithDelta(*active_model_, &delta);
136 } else {
137 SendStateUpdate(*active_model_);
138 }
139 }
text
std::u16string text
Definition: keyboard_unittests.cc:332

References text.

Referenced by flutter::testing::TEST_F().

## ◆ ComposeChangeHook()

void flutter::TextInputPlugin::ComposeChangeHook | ( | const std::u16string & | text,
|  | int | cursor_pos
| ) |  |
| virtual

Definition at line 193 of file text_input_plugin.cc.

194 {
195 if (active_model_ == nullptr) {
196 return;
197 }
198 std::string text_before_change = active_model_->GetText();
199 TextRange composing_before_change = active_model_->composing_range();
200 active_model_->AddText(text);
201 active_model_->UpdateComposingText(text, TextRange(cursor_pos, cursor_pos));
202 std::string text_after_change = active_model_->GetText();
203 if (enable_delta_model) {
204 TextEditingDelta delta = TextEditingDelta(
205 fml::Utf8ToUtf16(text_before_change), composing_before_change, text);
206 SendStateUpdateWithDelta(*active_model_, &delta);
207 } else {
208 SendStateUpdate(*active_model_);
209 }
210 }

References text.

Referenced by flutter::testing::TEST_F().

## ◆ ComposeCommitHook()

void flutter::TextInputPlugin::ComposeCommitHook | ( |  | ) |
| virtual

Definition at line 141 of file text_input_plugin.cc.

141 {
142 if (active_model_ == nullptr) {
143 return;
144 }
145 std::string text_before_change = active_model_->GetText();
146 TextRange selection_before_change = active_model_->selection();
147 TextRange composing_before_change = active_model_->composing_range();
148 std::string composing_text_before_change = text_before_change.substr(
149 composing_before_change.start(), composing_before_change.length());
150 active_model_->CommitComposing();
151
152 // We do not trigger SendStateUpdate here.
153 //
154 // Until a WM_IME_ENDCOMPOSING event, the user is still composing from the OS
155 // point of view. Commit events are always immediately followed by another
156 // composing event or an end composing event. However, in the brief window
157 // between the commit event and the following event, the composing region is
158 // collapsed. Notifying the framework of this intermediate state will trigger
159 // any framework code designed to execute at the end of composing, such as
160 // input formatters, which may try to update the text and send a message back
161 // to the engine with changes.
162 //
163 // This is a particular problem with Korean IMEs, which build up one
164 // character at a time in their composing region until a keypress that makes
165 // no sense for the in-progress character. At that point, the result
166 // character is committed and a compose event is immedidately received with
167 // the new composing region.
168 //
169 // In the case where this event is immediately followed by a composing event,
170 // the state will be sent in ComposeChangeHook.
171 //
172 // In the case where this event is immediately followed by an end composing
173 // event, the state will be sent in ComposeEndHook.
174 }

References flutter::TextRange::length(), and flutter::TextRange::start().

Referenced by flutter::testing::TEST_F().

## ◆ ComposeEndHook()

void flutter::TextInputPlugin::ComposeEndHook | ( |  | ) |
| virtual

Definition at line 176 of file text_input_plugin.cc.

176 {
177 if (active_model_ == nullptr) {
178 return;
179 }
180 std::string text_before_change = active_model_->GetText();
181 TextRange selection_before_change = active_model_->selection();
182 active_model_->CommitComposing();
183 active_model_->EndComposing();
184 if (enable_delta_model) {
185 std::string text = active_model_->GetText();
186 TextEditingDelta delta = TextEditingDelta(text);
187 SendStateUpdateWithDelta(*active_model_, &delta);
188 } else {
189 SendStateUpdate(*active_model_);
190 }
191 }

References text.

Referenced by flutter::testing::TEST_F().

## ◆ KeyboardHook()

void flutter::TextInputPlugin::KeyboardHook | ( | int | key,
|  | int | scancode,
|  | int | action,
|  | char32_t | character,
|  | bool | extended,
|  | bool | was_down
| ) |  |
| virtual

Definition at line 86 of file text_input_plugin.cc.

91 {
92 if (active_model_ == nullptr) {
93 return;
94 }
95 if (action == WM_KEYDOWN || action == WM_SYSKEYDOWN) {
96 // Most editing keys (arrow keys, backspace, delete, etc.) are handled in
97 // the framework, so don't need to be handled at this layer.
98 switch (key) {
99 case VK_RETURN:
100 EnterPressed(active_model_.get());
101 break;
102 default:
103 break;
104 }
105 }
106 }
key
int key
Definition: keyboard_key_handler_unittests.cc:114
action
int action
Definition: keyboard_key_handler_unittests.cc:116

References action, and key.

Referenced by flutter::testing::TEST_F().

## ◆ TextHook()

void flutter::TextInputPlugin::TextHook | ( | const std::u16string & | text | ) |
| virtual

Definition at line 68 of file text_input_plugin.cc.

68 {
69 if (active_model_ == nullptr) {
70 return;
71 }
72 std::u16string text_before_change =
73 fml::Utf8ToUtf16(active_model_->GetText());
74 TextRange selection_before_change = active_model_->selection();
75 active_model_->AddText(text);
76
77 if (enable_delta_model) {
78 TextEditingDelta delta =
79 TextEditingDelta(text_before_change, selection_before_change, text);
80 SendStateUpdateWithDelta(*active_model_, &delta);
81 } else {
82 SendStateUpdate(*active_model_);
83 }
84 }

References text.

## Friends And Related Function Documentation

## ◆ TextInputPluginModifier

friend class TextInputPluginModifier
| friend

Definition at line 75 of file text_input_plugin.h.

The documentation for this class was generated from the following files:

- shell/platform/windows/text_input_plugin.h
- shell/platform/windows/text_input_plugin.cc