Flutter Engine
flutter::TextInputPlugin Class Reference

#include <text_input_plugin.h>

Inheritance diagram for flutter::TextInputPlugin:
flutter::KeyboardHookHandler 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)
 
virtual ~TextInputPlugin ()
 
void KeyboardHook (FlutterWindowsView *view, int key, int scancode, int action, char32_t character) override
 
void TextHook (FlutterWindowsView *view, const std::u16string &text) override
 
- Public Member Functions inherited from flutter::KeyboardHookHandler
virtual ~KeyboardHookHandler ()=default
 
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(), TextRange::base(), 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(), flutter::TextInputModel::selection(), and ~TextInputPlugin().

Referenced by KeyboardHook().

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

◆ ~TextInputPlugin() [1/2]

flutter::TextInputPlugin::~TextInputPlugin ( )
virtualdefault

Referenced by KeyboardHook(), and TextInputPlugin().

◆ TextInputPlugin() [2/2]

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

◆ ~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 }

◆ 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.

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]

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

Implements flutter::KeyboardHookHandler.

Definition at line 55 of file text_input_plugin.cc.

References flutter::TextInputModel::AddText(), args, flutter::MethodCall< T >::arguments(), TextRange::base(), TextRange::extent(), flutter::JsonMethodCodec::GetInstance(), flutter::TextInputModel::GetText(), kAffinityDownstream, kBadArgumentError, kChannelName, 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(), flutter::TextInputModel::selection(), TextInputPlugin(), and ~TextInputPlugin().

59  {
60  if (active_model_ == nullptr) {
61  return;
62  }
63  if (action == WM_KEYDOWN) {
64  switch (key) {
65  case VK_LEFT:
66  if (active_model_->MoveCursorBack()) {
67  SendStateUpdate(*active_model_);
68  }
69  break;
70  case VK_RIGHT:
71  if (active_model_->MoveCursorForward()) {
72  SendStateUpdate(*active_model_);
73  }
74  break;
75  case VK_END:
76  active_model_->MoveCursorToEnd();
77  SendStateUpdate(*active_model_);
78  break;
79  case VK_HOME:
80  active_model_->MoveCursorToBeginning();
81  SendStateUpdate(*active_model_);
82  break;
83  case VK_BACK:
84  if (active_model_->Backspace()) {
85  SendStateUpdate(*active_model_);
86  }
87  break;
88  case VK_DELETE:
89  if (active_model_->Delete()) {
90  SendStateUpdate(*active_model_);
91  }
92  break;
93  case VK_RETURN:
94  EnterPressed(active_model_.get());
95  break;
96  default:
97  break;
98  }
99  }
100 }
SemanticsAction action

◆ TextHook()

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

Implements flutter::KeyboardHookHandler.

Definition at line 46 of file text_input_plugin.cc.

47  {
48  if (active_model_ == nullptr) {
49  return;
50  }
51  active_model_->AddText(text);
52  SendStateUpdate(*active_model_);
53 }

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