| Flutter Windows Embedder |

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

`#include <keyboard_key_handler.h>`

Inheritance diagram for flutter::KeyboardKeyHandler:

## 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

## 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,
35 kChannelName,
36 &StandardMethodCodec::GetInstance())) {}

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

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

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

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

## ◆ 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) {
99 FML_LOG(ERROR)
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 }

References action, callback, character, extended, key, scancode, and was_down.

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

## ◆ 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:

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

scancode
int scancode
Definition: keyboard_key_handler_unittests.cc:115
was_down
bool was_down
Definition: keyboard_key_handler_unittests.cc:119
extended
bool extended
Definition: keyboard_key_handler_unittests.cc:118
character
char32_t character
Definition: keyboard_key_handler_unittests.cc:117
kChannelName
static constexpr char kChannelName[]
Definition: cursor_handler.cc:13
action
int action
Definition: keyboard_key_handler_unittests.cc:116
key
int key
Definition: keyboard_key_handler_unittests.cc:114
flutter::StandardMethodCodec::GetInstance
static const StandardMethodCodec & GetInstance(const StandardCodecSerializer *serializer=nullptr)
Definition: standard_codec.cc:340
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:52