Skip to content

Commit

Permalink
Fix key events propagation (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
swift-kim authored Jun 7, 2022
1 parent 75d5353 commit 7b0c7a1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
5 changes: 3 additions & 2 deletions shell/platform/tizen/channels/platform_view_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,17 @@ void PlatformViewChannel::ClearViewFactories() {
view_factories_.clear();
}

void PlatformViewChannel::SendKey(const char* key,
bool PlatformViewChannel::SendKey(const char* key,
const char* string,
const char* compose,
uint32_t modifiers,
uint32_t scan_code,
bool is_down) {
PlatformView* view = FindFocusedView();
if (view) {
view->SendKey(key, string, compose, modifiers, scan_code, is_down);
return view->SendKey(key, string, compose, modifiers, scan_code, is_down);
}
return false;
}

void PlatformViewChannel::HandleMethodCall(
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/channels/platform_view_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PlatformViewChannel {
return view_factories_;
}

void SendKey(const char* key,
bool SendKey(const char* key,
const char* string,
const char* compose,
uint32_t modifiers,
Expand Down
16 changes: 9 additions & 7 deletions shell/platform/tizen/channels/text_input_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ bool TextInputChannel::SendKey(const char* key,
}

if (is_down) {
HandleKey(key, string, modifiers);
return HandleKey(key, string, modifiers);
}

return true;
return false;
}

void TextInputChannel::HandleMethodCall(
Expand Down Expand Up @@ -300,7 +300,7 @@ void TextInputChannel::SendStateUpdate() {
channel_->InvokeMethod(kUpdateEditingStateMethod, std::move(args));
}

void TextInputChannel::HandleKey(const char* key,
bool TextInputChannel::HandleKey(const char* key,
const char* string,
uint32_t modifires) {
bool shift = modifires & ECORE_SHIFT;
Expand Down Expand Up @@ -344,19 +344,21 @@ void TextInputChannel::HandleKey(const char* key,
needs_update = true;
} else if (key_str == "Return") {
EnterPressed();
return;
return true;
#ifdef TV_PROFILE
} else if (key_str == "Select") {
SelectPressed();
return;
} else {
return true;
#endif
FT_LOG(Warn) << "Key[" << key << "] is unhandled.";
} else {
FT_LOG(Info) << "Key[" << key << "] is unhandled.";
return false;
}

if (needs_update) {
SendStateUpdate();
}
return true;
}

void TextInputChannel::EnterPressed() {
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/channels/text_input_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TextInputChannel {
// Sends the current state of |active_model_| to the Flutter engine.
void SendStateUpdate();

void HandleKey(const char* key, const char* string, uint32_t modifiers);
bool HandleKey(const char* key, const char* string, uint32_t modifiers);

// Sends an action triggered by the Enter key to the Flutter engine.
void EnterPressed();
Expand Down
6 changes: 4 additions & 2 deletions shell/platform/tizen/flutter_tizen_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ void FlutterTizenView::OnKey(const char* key,
}

if (engine_->platform_view_channel()) {
engine_->platform_view_channel()->SendKey(key, string, compose, modifiers,
scan_code, is_down);
if (engine_->platform_view_channel()->SendKey(
key, string, compose, modifiers, scan_code, is_down)) {
return;
}
}

if (engine_->key_event_channel()) {
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/public/flutter_platform_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PlatformView {

bool IsFocused() { return is_focused_; }

virtual void SendKey(const char* key,
virtual bool SendKey(const char* key,
const char* string,
const char* compose,
uint32_t modifiers,
Expand Down

0 comments on commit 7b0c7a1

Please sign in to comment.