mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-27 00:41:04 +00:00
commit
7765504e8e
@ -122,43 +122,35 @@ declare namespace inputMethod {
|
||||
* Show soft keyboard
|
||||
* @since 9
|
||||
* @param callback
|
||||
* @return :
|
||||
* if true, success.
|
||||
* if false, fail.
|
||||
* @return : -
|
||||
* @syscap SystemCapability.MiscServices.InputMethodFramework
|
||||
*/
|
||||
showSoftKeyboard(callback: AsyncCallback<boolean>): void;
|
||||
showSoftKeyboard(callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* Show soft keyboard
|
||||
* @since 9
|
||||
* @return :
|
||||
* if true, success.
|
||||
* if false, fail.
|
||||
* @return : -
|
||||
* @syscap SystemCapability.MiscServices.InputMethodFramework
|
||||
*/
|
||||
showSoftKeyboard():Promise<boolean>;
|
||||
showSoftKeyboard():Promise<void>;
|
||||
|
||||
/**
|
||||
* Hide soft keyboard
|
||||
* @since 9
|
||||
* @param callback
|
||||
* @return :
|
||||
* if true, success.
|
||||
* if false, fail.
|
||||
* @return : -
|
||||
* @syscap SystemCapability.MiscServices.InputMethodFramework
|
||||
*/
|
||||
hideSoftKeyboard(callback: AsyncCallback<boolean>): void;
|
||||
hideSoftKeyboard(callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* Hide soft keyboard
|
||||
* @since 9
|
||||
* @return :
|
||||
* if true, success.
|
||||
* if false, fail.
|
||||
* @return : -
|
||||
* @syscap SystemCapability.MiscServices.InputMethodFramework
|
||||
*/
|
||||
hideSoftKeyboard():Promise<boolean>;
|
||||
hideSoftKeyboard():Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,7 @@ napi_value JsGetInputMethodController::GetInputMethodController(napi_env env, na
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodController::HandleSoftKeyboard(
|
||||
napi_env env, napi_callback_info info, std::function<int32_t()> callback)
|
||||
napi_env env, napi_callback_info info, std::function<int32_t()> callback, bool isOutput)
|
||||
{
|
||||
auto ctxt = std::make_shared<HandleContext>();
|
||||
auto input = [ctxt](napi_env env, size_t argc, napi_value *argv, napi_value self) -> napi_status {
|
||||
@ -105,24 +105,31 @@ napi_value JsGetInputMethodController::HandleSoftKeyboard(
|
||||
ctxt->isHandle = true;
|
||||
}
|
||||
};
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
if (isOutput) {
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
} else {
|
||||
ctxt->SetAction(std::move(input));
|
||||
}
|
||||
AsyncCall asyncCall(env, info, std::dynamic_pointer_cast<AsyncCall::Context>(ctxt), 0);
|
||||
return asyncCall.Call(env, exec);
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodController::ShowSoftKeyboard(napi_env env, napi_callback_info info)
|
||||
{
|
||||
return HandleSoftKeyboard(env, info, [] { return InputMethodController::GetInstance()->ShowCurrentInput(); });
|
||||
return HandleSoftKeyboard(
|
||||
env, info, [] { return InputMethodController::GetInstance()->ShowCurrentInput(); }, false);
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodController::HideSoftKeyboard(napi_env env, napi_callback_info info)
|
||||
{
|
||||
return HandleSoftKeyboard(env, info, [] { return InputMethodController::GetInstance()->HideCurrentInput(); });
|
||||
return HandleSoftKeyboard(
|
||||
env, info, [] { return InputMethodController::GetInstance()->HideCurrentInput(); }, false);
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodController::StopInput(napi_env env, napi_callback_info info)
|
||||
{
|
||||
return HandleSoftKeyboard(env, info, [] { return InputMethodController::GetInstance()->HideCurrentInput(); });
|
||||
return HandleSoftKeyboard(
|
||||
env, info, [] { return InputMethodController::GetInstance()->HideCurrentInput(); }, true);
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
@ -47,7 +47,8 @@ public:
|
||||
~JsGetInputMethodController() = default;
|
||||
static napi_value Init(napi_env env, napi_value info);
|
||||
static napi_value GetInputMethodController(napi_env env, napi_callback_info info);
|
||||
static napi_value HandleSoftKeyboard(napi_env env, napi_callback_info info, std::function<int32_t()> callback);
|
||||
static napi_value HandleSoftKeyboard(
|
||||
napi_env env, napi_callback_info info, std::function<int32_t()> callback, bool isOutput);
|
||||
static napi_value HideSoftKeyboard(napi_env env, napi_callback_info info);
|
||||
static napi_value ShowSoftKeyboard(napi_env env, napi_callback_info info);
|
||||
static napi_value StopInput(napi_env env, napi_callback_info info);
|
||||
|
Loading…
Reference in New Issue
Block a user