From 4f76cce13fbf19dc7272899b1a73f4122ddb4935 Mon Sep 17 00:00:00 2001 From: Seungsoo Lee Date: Wed, 20 Jan 2021 19:11:39 +0900 Subject: [PATCH] Fix a focused platform view bug * When a platform view is clicked, a "viewFocused" event has to be invoked for message channel. --- .../tizen/channels/platform_view_channel.cc | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/shell/platform/tizen/channels/platform_view_channel.cc b/shell/platform/tizen/channels/platform_view_channel.cc index 4cbaf21734116..6f71fd4856900 100644 --- a/shell/platform/tizen/channels/platform_view_channel.cc +++ b/shell/platform/tizen/channels/platform_view_channel.cc @@ -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"); @@ -147,15 +147,9 @@ void PlatformViewChannel::HandleMethodCall( auto viewInstance = it->second->Create(viewId, width, height, byteMessage); - viewInstance->SetFocus(true); view_instances_.insert( std::pair(viewId, viewInstance)); - if (channel_ != nullptr) { - auto id = std::make_unique(viewId); - channel_->InvokeMethod("viewFocused", std::move(id)); - } - if (engine_ && engine_->text_input_channel) { Ecore_IMF_Context* context = engine_->text_input_channel->GetImfContext(); @@ -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 { @@ -209,6 +204,20 @@ void PlatformViewChannel::HandleMethodCall( dy = std::get(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(viewId); + channel_->InvokeMethod("viewFocused", std::move(id)); + } + } + result->Success(); } else if (method == "setDirection") { FT_LOGD("PlatformViewChannel setDirection");