From cfee68123952860b0fb52c2c3a41d32cd3aa195d Mon Sep 17 00:00:00 2001 From: huangzhuozhen Date: Tue, 15 Apr 2025 10:16:02 +0800 Subject: [PATCH] add attachOptionsChanged with requestKeyboardReason fixed three Signed-off-by: huangzhuozhen --- .../inputmethodability/js_text_input_client_engine.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/frameworks/js/napi/inputmethodability/js_text_input_client_engine.cpp b/frameworks/js/napi/inputmethodability/js_text_input_client_engine.cpp index 8c63fb061..b7fcec913 100644 --- a/frameworks/js/napi/inputmethodability/js_text_input_client_engine.cpp +++ b/frameworks/js/napi/inputmethodability/js_text_input_client_engine.cpp @@ -1247,7 +1247,8 @@ napi_value JsTextInputClientEngine::GetAttachOptions(napi_env env, napi_callback bool flag = IsTargetDeviceType(DEVICE_TYPE_2IN1); if (!flag) { JsUtils::ThrowException( - env, JsUtils::Convert(IMFErrorCode::EXCEPTION_UNSUPPORTED), "only 2in1 supported!", TYPE_NONE); + env, JsUtils::Convert(ErrorCode::ERROR_DEVICE_UNSUPPORTED), "only 2in1 supported!", TYPE_NONE); + return JsUtil::Const::Null(env); } AttachOptions attachOptions; attachOptions.requestKeyboardReason = InputMethodAbility::GetInstance()->GetRequestKeyboardReason(); @@ -1271,7 +1272,8 @@ napi_value JsTextInputClientEngine::Subscribe(napi_env env, napi_callback_info i } if (type == "attachOptionsDidChange" && !IsTargetDeviceType(DEVICE_TYPE_2IN1)) { JsUtils::ThrowException( - env, JsUtils::Convert(IMFErrorCode::EXCEPTION_UNSUPPORTED), "only 2in1 supported!", TYPE_NONE); + env, JsUtils::Convert(ErrorCode::ERROR_DEVICE_UNSUPPORTED), "only 2in1 supported!", TYPE_NONE); + return JsUtil::Const::Null(env); } IMSA_HILOGD("subscribe type:%{public}s.", type.c_str()); auto engine = reinterpret_cast(JsUtils::GetNativeSelf(env, info)); @@ -1302,10 +1304,6 @@ napi_value JsTextInputClientEngine::UnSubscribe(napi_env env, napi_callback_info IMSA_HILOGE("unsubscribe failed, type: %{public}s!", type.c_str()); return nullptr; } - if (type == "attachOptionsDidChange" && !IsTargetDeviceType(DEVICE_TYPE_2IN1)) { - JsUtils::ThrowException( - env, JsUtils::Convert(IMFErrorCode::EXCEPTION_UNSUPPORTED), "only 2in1 supported!", TYPE_NONE); - } // if the second param is not napi_function/napi_null/napi_undefined, return auto paramType = JsUtil::GetType(env, argv[1]); if (paramType != napi_function && paramType != napi_null && paramType != napi_undefined) { -- Gitee