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