Skip to content

Commit

Permalink
Fix a focused platform view bug (#27)
Browse files Browse the repository at this point in the history
* When a platform view is clicked, a "viewFocused" event has to be invoked for message channel.
  • Loading branch information
seungsoo47 authored Jan 22, 2021
1 parent d28275e commit ac00eef
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions shell/platform/tizen/channels/platform_view_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void PlatformViewChannel::HandleMethodCall(
const auto method = call.method_name();
const auto& arguments = *call.arguments();

FT_LOGD("method: %s", method.c_str());
FT_LOGD("PlatformViewChannel method: %s", method.c_str());
if (method == "create") {
std::string viewType = ExtractStringFromMap(arguments, "viewType");
int viewId = ExtractIntFromMap(arguments, "id");
Expand All @@ -147,15 +147,9 @@ void PlatformViewChannel::HandleMethodCall(

auto viewInstance =
it->second->Create(viewId, width, height, byteMessage);
viewInstance->SetFocus(true);
view_instances_.insert(
std::pair<int, PlatformView*>(viewId, viewInstance));

if (channel_ != nullptr) {
auto id = std::make_unique<flutter::EncodableValue>(viewId);
channel_->InvokeMethod("viewFocused", std::move(id));
}

if (engine_ && engine_->text_input_channel) {
Ecore_IMF_Context* context =
engine_->text_input_channel->GetImfContext();
Expand All @@ -174,6 +168,7 @@ void PlatformViewChannel::HandleMethodCall(
};
auto it = view_instances_.find(viewId);
if (viewId >= 0 && it != view_instances_.end()) {
it->second->SetFocus(false);
it->second->ClearFocus();
result->Success();
} else {
Expand Down Expand Up @@ -209,6 +204,20 @@ void PlatformViewChannel::HandleMethodCall(
dy = std::get<double>(event[5]);

it->second->Touch(type, button, x, y, dx, dy);

if (!it->second->IsFocused()) {
auto focuesdView = view_instances_.find(CurrentFocusedViewId());
if (focuesdView != view_instances_.end()) {
focuesdView->second->SetFocus(false);
}

it->second->SetFocus(true);
if (channel_ != nullptr) {
auto id = std::make_unique<flutter::EncodableValue>(viewId);
channel_->InvokeMethod("viewFocused", std::move(id));
}
}

result->Success();
} else if (method == "setDirection") {
FT_LOGD("PlatformViewChannel setDirection");
Expand Down

0 comments on commit ac00eef

Please sign in to comment.