Skip to content

Commit ac00eef

Browse files
authored
Fix a focused platform view bug (#27)
* When a platform view is clicked, a "viewFocused" event has to be invoked for message channel.
1 parent d28275e commit ac00eef

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

shell/platform/tizen/channels/platform_view_channel.cc

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void PlatformViewChannel::HandleMethodCall(
121121
const auto method = call.method_name();
122122
const auto& arguments = *call.arguments();
123123

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

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

154-
if (channel_ != nullptr) {
155-
auto id = std::make_unique<flutter::EncodableValue>(viewId);
156-
channel_->InvokeMethod("viewFocused", std::move(id));
157-
}
158-
159153
if (engine_ && engine_->text_input_channel) {
160154
Ecore_IMF_Context* context =
161155
engine_->text_input_channel->GetImfContext();
@@ -174,6 +168,7 @@ void PlatformViewChannel::HandleMethodCall(
174168
};
175169
auto it = view_instances_.find(viewId);
176170
if (viewId >= 0 && it != view_instances_.end()) {
171+
it->second->SetFocus(false);
177172
it->second->ClearFocus();
178173
result->Success();
179174
} else {
@@ -209,6 +204,20 @@ void PlatformViewChannel::HandleMethodCall(
209204
dy = std::get<double>(event[5]);
210205

211206
it->second->Touch(type, button, x, y, dx, dy);
207+
208+
if (!it->second->IsFocused()) {
209+
auto focuesdView = view_instances_.find(CurrentFocusedViewId());
210+
if (focuesdView != view_instances_.end()) {
211+
focuesdView->second->SetFocus(false);
212+
}
213+
214+
it->second->SetFocus(true);
215+
if (channel_ != nullptr) {
216+
auto id = std::make_unique<flutter::EncodableValue>(viewId);
217+
channel_->InvokeMethod("viewFocused", std::move(id));
218+
}
219+
}
220+
212221
result->Success();
213222
} else if (method == "setDirection") {
214223
FT_LOGD("PlatformViewChannel setDirection");

0 commit comments

Comments
 (0)