@@ -121,7 +121,7 @@ void PlatformViewChannel::HandleMethodCall(
121
121
const auto method = call.method_name ();
122
122
const auto & arguments = *call.arguments ();
123
123
124
- FT_LOGD (" method: %s" , method.c_str ());
124
+ FT_LOGD (" PlatformViewChannel method: %s" , method.c_str ());
125
125
if (method == " create" ) {
126
126
std::string viewType = ExtractStringFromMap (arguments, " viewType" );
127
127
int viewId = ExtractIntFromMap (arguments, " id" );
@@ -147,15 +147,9 @@ void PlatformViewChannel::HandleMethodCall(
147
147
148
148
auto viewInstance =
149
149
it->second ->Create (viewId, width, height, byteMessage);
150
- viewInstance->SetFocus (true );
151
150
view_instances_.insert (
152
151
std::pair<int , PlatformView*>(viewId, viewInstance));
153
152
154
- if (channel_ != nullptr ) {
155
- auto id = std::make_unique<flutter::EncodableValue>(viewId);
156
- channel_->InvokeMethod (" viewFocused" , std::move (id));
157
- }
158
-
159
153
if (engine_ && engine_->text_input_channel ) {
160
154
Ecore_IMF_Context* context =
161
155
engine_->text_input_channel ->GetImfContext ();
@@ -174,6 +168,7 @@ void PlatformViewChannel::HandleMethodCall(
174
168
};
175
169
auto it = view_instances_.find (viewId);
176
170
if (viewId >= 0 && it != view_instances_.end ()) {
171
+ it->second ->SetFocus (false );
177
172
it->second ->ClearFocus ();
178
173
result->Success ();
179
174
} else {
@@ -209,6 +204,20 @@ void PlatformViewChannel::HandleMethodCall(
209
204
dy = std::get<double >(event[5 ]);
210
205
211
206
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
+
212
221
result->Success ();
213
222
} else if (method == " setDirection" ) {
214
223
FT_LOGD (" PlatformViewChannel setDirection" );
0 commit comments