Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
flutter::KeyboardKeyHandler Class Reference

#include <keyboard_key_handler.h>

Inheritance diagram for flutter::KeyboardKeyHandler:
flutter::KeyboardHandlerBase

Classes

class  KeyboardKeyHandlerDelegate
 

Public Member Functions

 KeyboardKeyHandler (flutter::BinaryMessenger *messenger)
 
 ~KeyboardKeyHandler ()
 
void InitKeyboardChannel ()
 
void AddDelegate (std::unique_ptr< KeyboardKeyHandlerDelegate > delegate)
 
void SyncModifiersIfNeeded (int modifiers_state) override
 
void KeyboardHook (int key, int scancode, int action, char32_t character, bool extended, bool was_down, KeyEventCallback callback) override
 
std::map< uint64_t, uint64_t > GetPressedState () override
 
- Public Member Functions inherited from flutter::KeyboardHandlerBase
virtual ~KeyboardHandlerBase ()=default
 
virtual void KeyboardHook (int key, int scancode, int action, char32_t character, bool extended, bool was_down, KeyEventCallback callback)=0
 
virtual void SyncModifiersIfNeeded (int modifiers_state)=0
 
virtual std::map< uint64_t, uint64_t > GetPressedState ()=0
 

Additional Inherited Members

- Public Types inherited from flutter::KeyboardHandlerBase
using KeyEventCallback = std::function< void(bool)>
 

Detailed Description

Definition at line 35 of file keyboard_key_handler.h.

Constructor & Destructor Documentation

◆ KeyboardKeyHandler()

flutter::KeyboardKeyHandler::KeyboardKeyHandler ( flutter::BinaryMessenger messenger)
explicit

Definition at line 31 of file keyboard_key_handler.cc.

32 : last_sequence_id_(1),
33 channel_(std::make_unique<MethodChannel<EncodableValue>>(
34 messenger,
static NSString *const kChannelName
static const StandardMethodCodec & GetInstance(const StandardCodecSerializer *serializer=nullptr)

◆ ~KeyboardKeyHandler()

flutter::KeyboardKeyHandler::~KeyboardKeyHandler ( )
default

Member Function Documentation

◆ AddDelegate()

void flutter::KeyboardKeyHandler::AddDelegate ( std::unique_ptr< KeyboardKeyHandlerDelegate delegate)

Definition at line 66 of file keyboard_key_handler.cc.

67 {
68 delegates_.push_back(std::move(delegate));
69}

◆ GetPressedState()

std::map< uint64_t, uint64_t > flutter::KeyboardKeyHandler::GetPressedState ( )
overridevirtual

Implements flutter::KeyboardHandlerBase.

Definition at line 77 of file keyboard_key_handler.cc.

77 {
78 // The embedder responder is the first element in delegates_.
79 auto& key_embedder_handler = delegates_.front();
80 return key_embedder_handler->GetPressedState();
81}

◆ InitKeyboardChannel()

void flutter::KeyboardKeyHandler::InitKeyboardChannel ( )

Definition at line 40 of file keyboard_key_handler.cc.

40 {
41 channel_->SetMethodCallHandler(
42 [this](const MethodCall<EncodableValue>& call,
43 std::unique_ptr<MethodResult<EncodableValue>> result) {
44 HandleMethodCall(call, std::move(result));
45 });
46}
GAsyncResult * result
def call(args)
Definition: dom.py:159

◆ KeyboardHook()

void flutter::KeyboardKeyHandler::KeyboardHook ( int  key,
int  scancode,
int  action,
char32_t  character,
bool  extended,
bool  was_down,
KeyEventCallback  callback 
)
overridevirtual

Implements flutter::KeyboardHandlerBase.

Definition at line 83 of file keyboard_key_handler.cc.

89 {
90 std::unique_ptr<PendingEvent> incoming = std::make_unique<PendingEvent>();
91
92 uint64_t sequence_id = ++last_sequence_id_;
93 incoming->sequence_id = sequence_id;
94 incoming->unreplied = delegates_.size();
95 incoming->any_handled = false;
96 incoming->callback = std::move(callback);
97
98 if (pending_responds_.size() > kMaxPendingEvents) {
100 << "There are " << pending_responds_.size()
101 << " keyboard events that have not yet received a response from the "
102 << "framework. Are responses being sent?";
103 }
104 pending_responds_.push_back(std::move(incoming));
105
106 for (const auto& delegate : delegates_) {
107 delegate->KeyboardHook(key, scancode, action, character, extended, was_down,
108 [sequence_id, this](bool handled) {
109 ResolvePendingEvent(sequence_id, handled);
110 });
111 }
112
113 // |ResolvePendingEvent| might trigger redispatching synchronously,
114 // which might occur before |KeyboardHook| is returned. This won't
115 // make events out of order though, because |KeyboardHook| will always
116 // return true at this time, preventing this event from affecting
117 // others.
118}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_LOG(severity)
Definition: logging.h:82
#define ERROR(message)
Definition: elf_loader.cc:260

◆ SyncModifiersIfNeeded()

void flutter::KeyboardKeyHandler::SyncModifiersIfNeeded ( int  modifiers_state)
overridevirtual

Implements flutter::KeyboardHandlerBase.

Definition at line 71 of file keyboard_key_handler.cc.

71 {
72 // Only call SyncModifierIfNeeded on the key embedder handler.
73 auto& key_embedder_handler = delegates_.front();
74 key_embedder_handler->SyncModifiersIfNeeded(modifiers_state);
75}

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