Flutter Engine
flutter::TextInputPlugin Class Reference

#include <text_input_plugin.h>

Inheritance diagram for flutter::TextInputPlugin:
flutter::KeyboardHandlerBase flutter::KeyboardHookHandler

Public Member Functions

 TextInputPlugin (flutter::BinaryMessenger *messenger)
 
virtual ~TextInputPlugin ()
 
void KeyboardHook (GLFWwindow *window, int key, int scancode, int action, int mods) override
 
void CharHook (GLFWwindow *window, unsigned int code_point) override
 
 TextInputPlugin (flutter::BinaryMessenger *messenger, TextInputPluginDelegate *delegate)
 
virtual ~TextInputPlugin ()
 
bool KeyboardHook (FlutterWindowsView *view, int key, int scancode, int action, char32_t character, bool extended, bool was_down) override
 
void TextHook (FlutterWindowsView *view, const std::u16string &text) override
 
void ComposeBeginHook () override
 
void ComposeCommitHook () override
 
void ComposeEndHook () override
 
void ComposeChangeHook (const std::u16string &text, int cursor_pos) override
 
- Public Member Functions inherited from flutter::KeyboardHandlerBase
virtual ~KeyboardHandlerBase ()=default
 
- Public Member Functions inherited from flutter::KeyboardHookHandler
virtual ~KeyboardHookHandler ()=default
 

Detailed Description

Definition at line 24 of file text_input_plugin.h.

Constructor & Destructor Documentation

◆ TextInputPlugin() [1/2]

flutter::TextInputPlugin::TextInputPlugin ( flutter::BinaryMessenger messenger)
explicit

Definition at line 99 of file text_input_plugin.cc.

References flutter::TextInputModel::AddCodePoint(), args, flutter::MethodCall< T >::arguments(), flutter::TextRange::base(), flutter::TextRange::extent(), flutter::TextInputModel::GetText(), kAffinityDownstream, kBadArgumentError, kClearClientMethod, kComposingBaseKey, kComposingExtentKey, kHideMethod, kInternalConsistencyError, kMultilineInputType, kPerformActionMethod, kSelectionAffinityKey, kSelectionBaseKey, kSelectionExtentKey, kSelectionIsDirectionalKey, kSetClientMethod, kSetEditingStateMethod, kShowMethod, kTextInputAction, kTextInputType, kTextInputTypeName, kTextKey, kUpdateEditingStateMethod, method_call, flutter::MethodCall< T >::method_name(), result, flutter::TextInputModel::selection(), text, and ~TextInputPlugin().

100  : channel_(std::make_unique<flutter::MethodChannel<rapidjson::Document>>(
101  messenger,
102  kChannelName,
104  active_model_(nullptr) {
105  channel_->SetMethodCallHandler(
106  [this](
109  HandleMethodCall(call, std::move(result));
110  });
111 }
static constexpr char kChannelName[]
static const JsonMethodCodec & GetInstance()
GAsyncResult * result

◆ ~TextInputPlugin() [1/2]

flutter::TextInputPlugin::~TextInputPlugin ( )
virtualdefault

Referenced by TextInputPlugin().

◆ TextInputPlugin() [2/2]

flutter::TextInputPlugin::TextInputPlugin ( flutter::BinaryMessenger messenger,
TextInputPluginDelegate delegate 
)
explicit

Definition at line 87 of file text_input_plugin.cc.

References result, and ~TextInputPlugin().

89  : channel_(std::make_unique<flutter::MethodChannel<rapidjson::Document>>(
90  messenger,
93  delegate_(delegate),
94  active_model_(nullptr) {
95  channel_->SetMethodCallHandler(
96  [this](
99  HandleMethodCall(call, std::move(result));
100  });
101 }
MockDelegate delegate_
static const JsonMethodCodec & GetInstance()
static constexpr char kChannelName[]
GAsyncResult * result

◆ ~TextInputPlugin() [2/2]

virtual flutter::TextInputPlugin::~TextInputPlugin ( )
virtual

Member Function Documentation

◆ CharHook()

void flutter::TextInputPlugin::CharHook ( GLFWwindow *  window,
unsigned int  code_point 
)
overridevirtual

Implements flutter::KeyboardHookHandler.

Definition at line 44 of file text_input_plugin.cc.

44  {
45  if (active_model_ == nullptr) {
46  return;
47  }
48  active_model_->AddCodePoint(code_point);
49  SendStateUpdate(*active_model_);
50 }

◆ ComposeBeginHook()

void flutter::TextInputPlugin::ComposeBeginHook ( )
overridevirtual

Implements flutter::KeyboardHandlerBase.

Definition at line 105 of file text_input_plugin.cc.

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

105  {
106  if (active_model_ == nullptr) {
107  return;
108  }
109  active_model_->BeginComposing();
110  SendStateUpdate(*active_model_);
111 }

◆ ComposeChangeHook()

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

Implements flutter::KeyboardHandlerBase.

Definition at line 130 of file text_input_plugin.cc.

References flutter::TextInputModel::AddText(), args, flutter::MethodCall< T >::arguments(), flutter::TextRange::base(), flutter::TextInputModel::composing(), flutter::TextInputModel::composing_range(), flutter::TextRange::extent(), flutter::TextInputModel::GetText(), height, flutter::Rect::height(), kAffinityDownstream, kBadArgumentError, kClearClientMethod, kComposingBaseKey, kComposingExtentKey, kHeightKey, kHideMethod, kInternalConsistencyError, kMultilineInputType, kPerformActionMethod, kSelectionAffinityKey, kSelectionBaseKey, kSelectionExtentKey, kSelectionIsDirectionalKey, kSetClientMethod, kSetEditableSizeAndTransform, kSetEditingStateMethod, kSetMarkedTextRect, kShowMethod, kTextInputAction, kTextInputType, kTextInputTypeName, kTextKey, kTransformKey, kUpdateEditingStateMethod, kWidthKey, kXKey, kYKey, flutter::Rect::left(), method_call, flutter::MethodCall< T >::method_name(), flutter::TextInputPluginDelegate::OnCursorRectUpdated(), flutter::TextInputPluginDelegate::OnResetImeComposing(), result, flutter::TextInputModel::selection(), flutter::Rect::size(), text, flutter::Rect::top(), flutter::transform, width, and flutter::Rect::width().

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

131  {
132  if (active_model_ == nullptr) {
133  return;
134  }
135  active_model_->AddText(text);
136  cursor_pos += active_model_->composing_range().base();
137  active_model_->UpdateComposingText(text);
138  active_model_->SetSelection(TextRange(cursor_pos, cursor_pos));
139  SendStateUpdate(*active_model_);
140 }
std::u16string text

◆ ComposeCommitHook()

void flutter::TextInputPlugin::ComposeCommitHook ( )
overridevirtual

Implements flutter::KeyboardHandlerBase.

Definition at line 113 of file text_input_plugin.cc.

113  {
114  if (active_model_ == nullptr) {
115  return;
116  }
117  active_model_->CommitComposing();
118  SendStateUpdate(*active_model_);
119 }

◆ ComposeEndHook()

void flutter::TextInputPlugin::ComposeEndHook ( )
overridevirtual

Implements flutter::KeyboardHandlerBase.

Definition at line 121 of file text_input_plugin.cc.

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

121  {
122  if (active_model_ == nullptr) {
123  return;
124  }
125  active_model_->CommitComposing();
126  active_model_->EndComposing();
127  SendStateUpdate(*active_model_);
128 }

◆ KeyboardHook() [1/2]

void flutter::TextInputPlugin::KeyboardHook ( GLFWwindow *  window,
int  key,
int  scancode,
int  action,
int  mods 
)
overridevirtual

Implements flutter::KeyboardHookHandler.

Definition at line 52 of file text_input_plugin.cc.

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

56  {
57  if (active_model_ == nullptr) {
58  return;
59  }
60  if (action == GLFW_PRESS || action == GLFW_REPEAT) {
61  switch (key) {
62  case GLFW_KEY_LEFT:
63  if (active_model_->MoveCursorBack()) {
64  SendStateUpdate(*active_model_);
65  }
66  break;
67  case GLFW_KEY_RIGHT:
68  if (active_model_->MoveCursorForward()) {
69  SendStateUpdate(*active_model_);
70  }
71  break;
72  case GLFW_KEY_END:
73  active_model_->MoveCursorToEnd();
74  SendStateUpdate(*active_model_);
75  break;
76  case GLFW_KEY_HOME:
77  active_model_->MoveCursorToBeginning();
78  SendStateUpdate(*active_model_);
79  break;
80  case GLFW_KEY_BACKSPACE:
81  if (active_model_->Backspace()) {
82  SendStateUpdate(*active_model_);
83  }
84  break;
85  case GLFW_KEY_DELETE:
86  if (active_model_->Delete()) {
87  SendStateUpdate(*active_model_);
88  }
89  break;
90  case GLFW_KEY_ENTER:
91  EnterPressed(active_model_.get());
92  break;
93  default:
94  break;
95  }
96  }
97 }
SemanticsAction action

◆ KeyboardHook() [2/2]

bool flutter::TextInputPlugin::KeyboardHook ( FlutterWindowsView view,
int  key,
int  scancode,
int  action,
char32_t  character,
bool  extended,
bool  was_down 
)
overridevirtual

Implements flutter::KeyboardHandlerBase.

Definition at line 63 of file text_input_plugin.cc.

69  {
70  if (active_model_ == nullptr) {
71  return false;
72  }
73  if (action == WM_KEYDOWN) {
74  // Most editing keys (arrow keys, backspace, delete, etc.) are handled in
75  // the framework, so don't need to be handled at this layer.
76  switch (key) {
77  case VK_RETURN:
78  EnterPressed(active_model_.get());
79  break;
80  default:
81  break;
82  }
83  }
84  return false;
85 }
SemanticsAction action

◆ TextHook()

void flutter::TextInputPlugin::TextHook ( FlutterWindowsView view,
const std::u16string &  text 
)
overridevirtual

Implements flutter::KeyboardHandlerBase.

Definition at line 54 of file text_input_plugin.cc.

55  {
56  if (active_model_ == nullptr) {
57  return;
58  }
59  active_model_->AddText(text);
60  SendStateUpdate(*active_model_);
61 }
std::u16string text

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