diff --git a/ohos_nweb/src/nweb_inputmethod_handler.cc b/ohos_nweb/src/nweb_inputmethod_handler.cc index bae1c950d9b81fefaf43a9d29b116765d3e61c27..64d9738ec270497042721ae7a09f8ede7cfa5720 100644 --- a/ohos_nweb/src/nweb_inputmethod_handler.cc +++ b/ohos_nweb/src/nweb_inputmethod_handler.cc @@ -168,12 +168,16 @@ void NWebInputMethodHandler::Attach(CefRefPtr browser, IMFAdapterCursorInfo cursorInfo = GetCursorInfo(); IMFAdapterTextConfig textConfig = { .inputAttribute = inputAttribute, .cursorInfo = cursorInfo }; + if (!show_keyboard_ && isAttached_) { + LOG(ERROR) << "do not need attach"; + return; + } if (!inputmethod_adapter_->Attach(inputmethod_listener_, show_keyboard_, textConfig)) { LOG(ERROR) << "inputmethod_adapter_ attach failed"; return; } isAttached_ = true; - lastAttachNWebId_ = nweb_Id_; + lastAttachNWebId_ = nweb_id_; if (focus_status_ && focus_rect_status_) { if (inputmethod_adapter_) { @@ -183,7 +187,7 @@ void NWebInputMethodHandler::Attach(CefRefPtr browser, } bool NWebInputMethodHandler::Reattach(uint32_t nwebId, ReattachType type) { - nweb_Id_ = nwebId; + nweb_id_ = nwebId; if (type == ReattachType::FROM_CONTINUE) { if (!isNeedReattachOncontinue_) { LOG(INFO) << "don't need reattach input method"; @@ -220,6 +224,10 @@ bool NWebInputMethodHandler::Reattach(uint32_t nwebId, ReattachType type) { IMFAdapterCursorInfo cursorInfo = GetCursorInfo(); IMFAdapterTextConfig textConfig = { .inputAttribute = inputAttribute, .cursorInfo = cursorInfo }; + if (!show_keyboard_ && isAttached_) { + LOG(ERROR) << "do not need attach"; + return true; + } if (!inputmethod_adapter_->Attach(inputmethod_listener_, show_keyboard_, textConfig)) { LOG(ERROR) << "inputmethod_adapter_ attach failed"; return false; diff --git a/ohos_nweb/src/nweb_inputmethod_handler.h b/ohos_nweb/src/nweb_inputmethod_handler.h index f7f2b13d02a4033d2f8ce644ed4e0d16518b13a7..0649bb8af50d3948d82bbd49505942f7b3cb9eee 100644 --- a/ohos_nweb/src/nweb_inputmethod_handler.h +++ b/ohos_nweb/src/nweb_inputmethod_handler.h @@ -69,7 +69,7 @@ class NWebInputMethodHandler : public NWebInputMethodClient { IMFAdapterCursorInfo GetCursorInfo(); static uint32_t lastAttachNWebId_; - uint32_t nweb_Id_ = 0; + uint32_t nweb_id_ = 0; CefRefPtr browser_; bool ime_shown_ = false; bool ime_text_composing_ = false;