mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-24 15:21:02 +00:00
Merge branch 'master' of gitee.com:openharmony/inputmethod_imf into master
Signed-off-by: cy7717 <chenyu301@huawei.com>
This commit is contained in:
commit
c5496c0b4c
@ -71,6 +71,10 @@ napi_value JsInputMethodEngineSetting::Init(napi_env env, napi_value exports)
|
||||
|
||||
DECLARE_NAPI_FUNCTION("getInputMethodEngine", GetInputMethodEngine),
|
||||
DECLARE_NAPI_FUNCTION("getInputMethodAbility", GetInputMethodAbility),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("PanelType", GetJsPanelTypeProperty(env)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("PanelFlag", GetJsPanelFlagProperty(env)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("Direction", GetJsDirectionProperty(env)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("ExtendAction", GetJsExtendActionProperty(env)),
|
||||
};
|
||||
NAPI_CALL(
|
||||
env, napi_define_properties(env, exports, sizeof(descriptor) / sizeof(napi_property_descriptor), descriptor));
|
||||
@ -103,6 +107,70 @@ napi_value JsInputMethodEngineSetting::GetIntJsConstProperty(napi_env env, int32
|
||||
return jsNumber;
|
||||
}
|
||||
|
||||
napi_value JsInputMethodEngineSetting::GetJsPanelTypeProperty(napi_env env)
|
||||
{
|
||||
napi_value panelType = nullptr;
|
||||
napi_value typeSoftKeyboard = nullptr;
|
||||
napi_value typeStatusBar = nullptr;
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(PanelType::SOFT_KEYBOARD), &typeSoftKeyboard));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(PanelType::STATUS_BAR), &typeStatusBar));
|
||||
NAPI_CALL(env, napi_create_object(env, &panelType));
|
||||
NAPI_CALL(env, napi_set_named_property(env, panelType, "SOFT_KEYBOARD", typeSoftKeyboard));
|
||||
NAPI_CALL(env, napi_set_named_property(env, panelType, "STATUS_BAR", typeStatusBar));
|
||||
return panelType;
|
||||
}
|
||||
|
||||
napi_value JsInputMethodEngineSetting::GetJsPanelFlagProperty(napi_env env)
|
||||
{
|
||||
napi_value panelFlag = nullptr;
|
||||
napi_value flagFixed = nullptr;
|
||||
napi_value flagFloating = nullptr;
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(PanelFlag::FLG_FIXED), &flagFixed));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(PanelFlag::FLG_FLOATING), &flagFloating));
|
||||
NAPI_CALL(env, napi_create_object(env, &panelFlag));
|
||||
NAPI_CALL(env, napi_set_named_property(env, panelFlag, "FLG_FIXED", flagFixed));
|
||||
NAPI_CALL(env, napi_set_named_property(env, panelFlag, "FLG_FLOATING", flagFloating));
|
||||
return panelFlag;
|
||||
}
|
||||
|
||||
napi_value JsInputMethodEngineSetting::GetJsDirectionProperty(napi_env env)
|
||||
{
|
||||
napi_value direction = nullptr;
|
||||
napi_value cursorUp = nullptr;
|
||||
napi_value cursorDown = nullptr;
|
||||
napi_value cursorLeft = nullptr;
|
||||
napi_value cursorRight = nullptr;
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(Direction::UP), &cursorUp));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(Direction::DOWN), &cursorDown));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(Direction::LEFT), &cursorLeft));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(Direction::RIGHT), &cursorRight));
|
||||
NAPI_CALL(env, napi_create_object(env, &direction));
|
||||
NAPI_CALL(env, napi_set_named_property(env, direction, "CURSOR_UP", cursorUp));
|
||||
NAPI_CALL(env, napi_set_named_property(env, direction, "CURSOR_DOWN", cursorDown));
|
||||
NAPI_CALL(env, napi_set_named_property(env, direction, "CURSOR_LEFT", cursorLeft));
|
||||
NAPI_CALL(env, napi_set_named_property(env, direction, "CURSOR_RIGHT", cursorRight));
|
||||
return direction;
|
||||
}
|
||||
|
||||
napi_value JsInputMethodEngineSetting::GetJsExtendActionProperty(napi_env env)
|
||||
{
|
||||
napi_value action = nullptr;
|
||||
napi_value actionSelectAll = nullptr;
|
||||
napi_value actionCut = nullptr;
|
||||
napi_value actionCopy = nullptr;
|
||||
napi_value actionPaste = nullptr;
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(ExtendAction::SELECT_ALL), &actionSelectAll));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(ExtendAction::CUT), &actionCut));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(ExtendAction::COPY), &actionCopy));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(ExtendAction::PASTE), &actionPaste));
|
||||
NAPI_CALL(env, napi_create_object(env, &action));
|
||||
NAPI_CALL(env, napi_set_named_property(env, action, "SELECT_ALL", actionSelectAll));
|
||||
NAPI_CALL(env, napi_set_named_property(env, action, "CUT", actionCut));
|
||||
NAPI_CALL(env, napi_set_named_property(env, action, "COPY", actionCopy));
|
||||
NAPI_CALL(env, napi_set_named_property(env, action, "PASTE", actionPaste));
|
||||
return action;
|
||||
}
|
||||
|
||||
std::shared_ptr<JsInputMethodEngineSetting> JsInputMethodEngineSetting::GetInputMethodEngineSetting()
|
||||
{
|
||||
if (inputMethodEngine_ == nullptr) {
|
||||
@ -303,20 +371,22 @@ napi_value JsInputMethodEngineSetting::CreatePanel(napi_env env, napi_callback_i
|
||||
|
||||
auto output = [ctxt](napi_env env, napi_value *result) -> napi_status {
|
||||
JsPanel *jsPanel = nullptr;
|
||||
napi_ref ref = New(env, reinterpret_cast<void **>(&jsPanel), JsPanel::Constructor(env));
|
||||
NAPI_ASSERT_BASE(env, (ref != nullptr) && (jsPanel != nullptr), "get jsPanel instance failed!",
|
||||
napi_generic_failure);
|
||||
napi_value constructor = JsPanel::Init(env);
|
||||
NAPI_ASSERT_BASE(env, constructor != nullptr, "get jsPanel constructor failed!", napi_generic_failure);
|
||||
|
||||
napi_status status = napi_new_instance(env, constructor, 0, nullptr, result);
|
||||
NAPI_ASSERT_BASE(env, status == napi_ok, "get jsPanel instance failed!", napi_generic_failure);
|
||||
|
||||
status = napi_unwrap(env, *result, (void **)(&jsPanel));
|
||||
NAPI_ASSERT_BASE(env, (status == napi_ok) && (jsPanel != nullptr), "get jsPanel failed", napi_generic_failure);
|
||||
jsPanel->SetNative(ctxt->panel);
|
||||
auto status = napi_get_reference_value(env, ref, result);
|
||||
NAPI_ASSERT_BASE(env, (status == napi_ok || result != nullptr), "Get ref error!", napi_generic_failure);
|
||||
napi_delete_reference(env, ref);
|
||||
return napi_ok;
|
||||
};
|
||||
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 3 means JsAPI:createPanel has 3 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 3);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "createPanel");
|
||||
}
|
||||
|
||||
napi_value JsInputMethodEngineSetting::DestroyPanel(napi_env env, napi_callback_info info)
|
||||
@ -328,12 +398,9 @@ napi_value JsInputMethodEngineSetting::DestroyPanel(napi_env env, napi_callback_
|
||||
napi_typeof(env, argv[0], &valueType);
|
||||
PARAM_CHECK_RETURN(env, valueType == napi_object, " target: ", TYPE_OBJECT, napi_invalid_arg);
|
||||
bool isPanel = false;
|
||||
napi_value constructor = nullptr;
|
||||
NAPI_ASSERT_BASE(env, JsPanel::panelConstructorRef_ != nullptr,
|
||||
"the panel which will be destroy is not exist!", napi_invalid_arg);
|
||||
napi_status status = napi_get_reference_value(env, JsPanel::panelConstructorRef_, &constructor);
|
||||
NAPI_ASSERT_BASE(env, status == napi_ok, "Failed to get panel constructor.", status);
|
||||
status = napi_instanceof(env, argv[0], constructor, &isPanel);
|
||||
napi_value constructor = JsPanel::Init(env);
|
||||
NAPI_ASSERT_BASE(env, constructor != nullptr, "Failed to get panel constructor.", napi_invalid_arg);
|
||||
napi_status status = napi_instanceof(env, argv[0], constructor, &isPanel);
|
||||
NAPI_ASSERT_BASE(env, (status == napi_ok) && isPanel, "It's not expected panel instance!", status);
|
||||
JsPanel *jsPanel = nullptr;
|
||||
status = napi_unwrap(env, argv[0], (void **)(&jsPanel));
|
||||
@ -344,35 +411,24 @@ napi_value JsInputMethodEngineSetting::DestroyPanel(napi_env env, napi_callback_
|
||||
};
|
||||
|
||||
auto exec = [ctxt](AsyncCall::Context *ctx) {
|
||||
CHECK_RETURN_VOID((ctxt->panel != nullptr), "inputMethodPanel is nullptr!");
|
||||
ctxt->SetState(napi_ok);
|
||||
};
|
||||
|
||||
auto output = [ctxt](napi_env env, napi_value *result) -> napi_status {
|
||||
NAPI_ASSERT_BASE(env, (ctxt->panel != nullptr), "inputMethodPanel is nullptr!", napi_generic_failure);
|
||||
auto errCode = InputMethodAbility::GetInstance()->DestroyPanel(ctxt->panel);
|
||||
if (errCode != ErrorCode::NO_ERROR) {
|
||||
IMSA_HILOGE("DestroyPanel failed, errCode = %{public}d", errCode);
|
||||
return;
|
||||
return napi_generic_failure;
|
||||
}
|
||||
ctxt->SetState(napi_ok);
|
||||
ctxt->panel = nullptr;
|
||||
return napi_ok;
|
||||
};
|
||||
|
||||
ctxt->SetAction(std::move(input));
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 2 means JsAPI:destroyPanel has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
}
|
||||
|
||||
napi_ref JsInputMethodEngineSetting::New(napi_env env, void **out, napi_value constructor)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_status status = napi_new_instance(env, constructor, 0, nullptr, &object);
|
||||
NAPI_ASSERT(env, (status == napi_ok) && (object != nullptr), "napi_new_instance failed!");
|
||||
|
||||
status = napi_unwrap(env, object, out);
|
||||
NAPI_ASSERT(env, (status == napi_ok) && (out != nullptr), "napi_unwrap failed");
|
||||
|
||||
napi_ref ref = nullptr;
|
||||
status = napi_create_reference(env, object, 1, &ref);
|
||||
NAPI_ASSERT(env, (status == napi_ok) && (ref != nullptr), "napi_create_reference failed");
|
||||
return ref;
|
||||
return asyncCall.Call(env, exec, "destroyPanel");
|
||||
}
|
||||
|
||||
napi_value JsInputMethodEngineSetting::UnSubscribe(napi_env env, napi_callback_info info)
|
||||
|
@ -78,6 +78,10 @@ private:
|
||||
static std::shared_ptr<JsInputMethodEngineSetting> GetInputMethodEngineSetting();
|
||||
static bool InitInputMethodSetting();
|
||||
static napi_value GetJsConstProperty(napi_env env, uint32_t num);
|
||||
static napi_value GetJsPanelTypeProperty(napi_env env);
|
||||
static napi_value GetJsPanelFlagProperty(napi_env env);
|
||||
static napi_value GetJsDirectionProperty(napi_env env);
|
||||
static napi_value GetJsExtendActionProperty(napi_env env);
|
||||
static napi_value GetIntJsConstProperty(napi_env env, int32_t num);
|
||||
static napi_value GetIMEInstance(napi_env env, napi_callback_info info);
|
||||
static napi_status GetContext(napi_env env, napi_value argv,
|
||||
@ -85,7 +89,6 @@ private:
|
||||
void RegisterListener(napi_value callback, std::string type, std::shared_ptr<JSCallbackObject> callbackObj);
|
||||
void UnRegisterListener(napi_value callback, std::string type);
|
||||
static napi_value GetResultOnSetSubtype(napi_env env, const SubProperty &property);
|
||||
static napi_ref New(napi_env env, void **out, napi_value constructor);
|
||||
static const std::string IMES_CLASS_NAME;
|
||||
static thread_local napi_ref IMESRef_;
|
||||
struct UvEntry {
|
||||
|
@ -100,7 +100,7 @@ napi_value JsKeyboardControllerEngine::Hide(napi_env env, napi_callback_info inf
|
||||
ctxt->SetAction(std::move(input));
|
||||
// 1 means JsAPI:hide has 1 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 1);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "keyboard.hide");
|
||||
}
|
||||
|
||||
napi_value JsKeyboardControllerEngine::HideKeyboard(napi_env env, napi_callback_info info)
|
||||
@ -115,7 +115,7 @@ napi_value JsKeyboardControllerEngine::HideKeyboard(napi_env env, napi_callback_
|
||||
ctxt->SetAction(std::move(input));
|
||||
// 1 means JsAPI:hideKeyboard has 1 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 1);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "hideKeyboard");
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
@ -28,9 +28,18 @@ const std::string JsPanel::CLASS_NAME = "Panel";
|
||||
thread_local napi_ref JsPanel::panelConstructorRef_ = nullptr;
|
||||
constexpr size_t ARGC_ONE = 1;
|
||||
constexpr size_t ARGC_TWO = 2;
|
||||
napi_value JsPanel::Constructor(napi_env env)
|
||||
std::mutex JsPanel::panelConstructorMutex_;
|
||||
|
||||
napi_value JsPanel::Init(napi_env env)
|
||||
{
|
||||
IMSA_HILOGI("JsPanel in.");
|
||||
napi_value constructor = nullptr;
|
||||
std::lock_guard<std::mutex> lock(panelConstructorMutex_);
|
||||
if (panelConstructorRef_ != nullptr) {
|
||||
napi_status status = napi_get_reference_value(env, panelConstructorRef_, &constructor);
|
||||
NAPI_ASSERT_BASE(env, status == napi_ok, "Failed to get jsPanel constructor.", nullptr);
|
||||
return constructor;
|
||||
}
|
||||
const napi_property_descriptor properties[] = {
|
||||
DECLARE_NAPI_FUNCTION("setUiContent", SetUiContent),
|
||||
DECLARE_NAPI_FUNCTION("resize", Resize),
|
||||
@ -41,7 +50,6 @@ napi_value JsPanel::Constructor(napi_env env)
|
||||
DECLARE_NAPI_FUNCTION("on", Subscribe),
|
||||
DECLARE_NAPI_FUNCTION("off", UnSubscribe),
|
||||
};
|
||||
napi_value constructor = nullptr;
|
||||
NAPI_CALL(env, napi_define_class(env, CLASS_NAME.c_str(), CLASS_NAME.size(), JsNew, nullptr,
|
||||
sizeof(properties) / sizeof(napi_property_descriptor), properties, &constructor));
|
||||
NAPI_ASSERT(env, constructor != nullptr, "napi_define_class failed!");
|
||||
@ -115,21 +123,18 @@ napi_value JsPanel::SetUiContent(napi_env env, napi_callback_info info)
|
||||
return napi_ok;
|
||||
};
|
||||
|
||||
auto exec = [ctxt](AsyncCall::Context *ctx) {
|
||||
ctxt->SetState(napi_ok);
|
||||
};
|
||||
auto exec = [ctxt](AsyncCall::Context *ctx) { ctxt->SetState(napi_ok); };
|
||||
auto output = [ctxt](napi_env env, napi_value *result) -> napi_status {
|
||||
auto &inputMethodPanel = reinterpret_cast<JsPanel *>(ctxt->native)->GetNative();
|
||||
NAPI_ASSERT_BASE(env, inputMethodPanel != nullptr, "inputMethodPanel is nullptr!", napi_generic_failure);
|
||||
auto code = inputMethodPanel->SetUiContent(ctxt->path, *(reinterpret_cast<NativeEngine *>(env)),
|
||||
ctxt->contentStorage);
|
||||
NAPI_ASSERT_BASE(env, ctxt->inputMethodPanel != nullptr, "inputMethodPanel is nullptr!", napi_generic_failure);
|
||||
auto code = ctxt->inputMethodPanel->SetUiContent(
|
||||
ctxt->path, *(reinterpret_cast<NativeEngine *>(env)), ctxt->contentStorage);
|
||||
NAPI_ASSERT_BASE(env, code == ErrorCode::NO_ERROR, "SetUiContent failed!", napi_generic_failure);
|
||||
return napi_ok;
|
||||
};
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 3 means JsAPI:setUiContent has 3 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 3);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "setUiContent");
|
||||
}
|
||||
|
||||
napi_value JsPanel::Resize(napi_env env, napi_callback_info info)
|
||||
@ -148,9 +153,8 @@ napi_value JsPanel::Resize(napi_env env, napi_callback_info info)
|
||||
};
|
||||
|
||||
auto exec = [ctxt](AsyncCall::Context *ctx) {
|
||||
auto &inputMethodPanel = reinterpret_cast<JsPanel *>(ctxt->native)->GetNative();
|
||||
CHECK_RETURN_VOID(inputMethodPanel != nullptr, "inputMethodPanel_ is nullptr.");
|
||||
auto code = inputMethodPanel->Resize(ctxt->width, ctxt->height);
|
||||
CHECK_RETURN_VOID(ctxt->inputMethodPanel != nullptr, "inputMethodPanel_ is nullptr.");
|
||||
auto code = ctxt->inputMethodPanel->Resize(ctxt->width, ctxt->height);
|
||||
if (code == ErrorCode::NO_ERROR) {
|
||||
ctxt->SetState(napi_ok);
|
||||
return;
|
||||
@ -160,7 +164,7 @@ napi_value JsPanel::Resize(napi_env env, napi_callback_info info)
|
||||
ctxt->SetAction(std::move(input));
|
||||
// 3 means JsAPI:resize has 3 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 3);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "resize");
|
||||
}
|
||||
|
||||
napi_value JsPanel::MoveTo(napi_env env, napi_callback_info info)
|
||||
@ -179,9 +183,8 @@ napi_value JsPanel::MoveTo(napi_env env, napi_callback_info info)
|
||||
};
|
||||
|
||||
auto exec = [ctxt](AsyncCall::Context *ctx) {
|
||||
auto &inputMethodPanel = reinterpret_cast<JsPanel *>(ctxt->native)->GetNative();
|
||||
CHECK_RETURN_VOID(inputMethodPanel != nullptr, "inputMethodPanel_ is nullptr.");
|
||||
auto code = inputMethodPanel->MoveTo(ctxt->x, ctxt->y);
|
||||
CHECK_RETURN_VOID(ctxt->inputMethodPanel != nullptr, "inputMethodPanel_ is nullptr.");
|
||||
auto code = ctxt->inputMethodPanel->MoveTo(ctxt->x, ctxt->y);
|
||||
if (code == ErrorCode::NO_ERROR) {
|
||||
ctxt->SetState(napi_ok);
|
||||
return;
|
||||
@ -191,16 +194,15 @@ napi_value JsPanel::MoveTo(napi_env env, napi_callback_info info)
|
||||
ctxt->SetAction(std::move(input));
|
||||
// 3 means JsAPI:moveTo has 3 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 3);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "moveTo");
|
||||
}
|
||||
|
||||
napi_value JsPanel::Show(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto ctxt = std::make_shared<PanelContentContext>(env, info);
|
||||
auto exec = [ctxt](AsyncCall::Context *ctx) {
|
||||
auto &inputMethodPanel = reinterpret_cast<JsPanel *>(ctxt->native)->GetNative();
|
||||
CHECK_RETURN_VOID(inputMethodPanel != nullptr, "inputMethodPanel_ is nullptr.");
|
||||
auto code = inputMethodPanel->ShowPanel();
|
||||
CHECK_RETURN_VOID(ctxt->inputMethodPanel != nullptr, "inputMethodPanel_ is nullptr.");
|
||||
auto code = ctxt->inputMethodPanel->ShowPanel();
|
||||
if (code == ErrorCode::NO_ERROR) {
|
||||
ctxt->SetState(napi_ok);
|
||||
return;
|
||||
@ -209,16 +211,15 @@ napi_value JsPanel::Show(napi_env env, napi_callback_info info)
|
||||
};
|
||||
// 1 means JsAPI:show has 1 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 1);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "show");
|
||||
}
|
||||
|
||||
napi_value JsPanel::Hide(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto ctxt = std::make_shared<PanelContentContext>(env, info);
|
||||
auto exec = [ctxt](AsyncCall::Context *ctx) {
|
||||
auto &inputMethodPanel = reinterpret_cast<JsPanel *>(ctxt->native)->GetNative();
|
||||
CHECK_RETURN_VOID(inputMethodPanel != nullptr, "inputMethodPanel_ is nullptr.");
|
||||
auto code = inputMethodPanel->HidePanel();
|
||||
CHECK_RETURN_VOID(ctxt->inputMethodPanel != nullptr, "inputMethodPanel_ is nullptr.");
|
||||
auto code = ctxt->inputMethodPanel->HidePanel();
|
||||
if (code == ErrorCode::NO_ERROR) {
|
||||
ctxt->SetState(napi_ok);
|
||||
return;
|
||||
@ -227,7 +228,7 @@ napi_value JsPanel::Hide(napi_env env, napi_callback_info info)
|
||||
};
|
||||
// 1 means JsAPI:hide has 1 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 1);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "panel.hide");
|
||||
}
|
||||
|
||||
napi_value JsPanel::ChangeFlag(napi_env env, napi_callback_info info)
|
||||
|
@ -16,6 +16,7 @@
|
||||
#ifndef INPUTMETHOD_IMF_JSPANEL_H
|
||||
#define INPUTMETHOD_IMF_JSPANEL_H
|
||||
|
||||
#include <mutex>
|
||||
#include <uv.h>
|
||||
|
||||
#include "async_call.h"
|
||||
@ -33,7 +34,7 @@ class JsPanel {
|
||||
public:
|
||||
JsPanel() = default;
|
||||
~JsPanel();
|
||||
static napi_value Constructor(napi_env env);
|
||||
static napi_value Init(napi_env env);
|
||||
static napi_value SetUiContent(napi_env env, napi_callback_info info);
|
||||
static napi_value Resize(napi_env env, napi_callback_info info);
|
||||
static napi_value MoveTo(napi_env env, napi_callback_info info);
|
||||
@ -44,7 +45,7 @@ public:
|
||||
static napi_value UnSubscribe(napi_env env, napi_callback_info info);
|
||||
void SetNative(const std::shared_ptr<InputMethodPanel> &panel);
|
||||
std::shared_ptr<InputMethodPanel> &GetNative();
|
||||
static thread_local napi_ref panelConstructorRef_;
|
||||
|
||||
private:
|
||||
struct PanelContentContext : public AsyncCall::Context {
|
||||
std::string path = "";
|
||||
@ -52,13 +53,17 @@ private:
|
||||
uint32_t height = 0;
|
||||
int32_t x = 0;
|
||||
int32_t y = 0;
|
||||
void *native = nullptr;
|
||||
std::shared_ptr<InputMethodPanel> inputMethodPanel = nullptr;
|
||||
std::shared_ptr<NativeReference> contentStorage = nullptr;
|
||||
PanelContentContext(napi_env env, napi_callback_info info) : Context(nullptr, nullptr)
|
||||
{
|
||||
napi_value self = nullptr;
|
||||
napi_status status = napi_get_cb_info(env, info, 0, nullptr, &self, nullptr);
|
||||
CHECK_RETURN_VOID((status == napi_ok) && (self != nullptr), "get callback info failed.");
|
||||
void *native = nullptr;
|
||||
status = napi_unwrap(env, self, &native);
|
||||
CHECK_RETURN_VOID((status == napi_ok) && (native != nullptr), "get jsPanel failed.");
|
||||
inputMethodPanel = reinterpret_cast<JsPanel *>(native)->GetNative();
|
||||
};
|
||||
PanelContentContext(InputAction input, OutputAction output) : Context(std::move(input), std::move(output)){};
|
||||
napi_status operator()(napi_env env, size_t argc, napi_value *argv, napi_value self) override
|
||||
@ -80,6 +85,9 @@ private:
|
||||
static const std::string CLASS_NAME;
|
||||
static constexpr size_t ARGC_MAX = 6;
|
||||
std::shared_ptr<InputMethodPanel> inputMethodPanel_ = nullptr;
|
||||
|
||||
static std::mutex panelConstructorMutex_;
|
||||
static thread_local napi_ref panelConstructorRef_;
|
||||
};
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -71,7 +71,7 @@ napi_value JsTextInputClientEngine::MoveCursor(napi_env env, napi_callback_info
|
||||
ctxt->SetAction(std::move(input));
|
||||
// 2 means JsAPI:moveCursor has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "moveCursor");
|
||||
}
|
||||
|
||||
napi_value JsTextInputClientEngine::JsConstructor(napi_env env, napi_callback_info cbinfo)
|
||||
@ -197,7 +197,7 @@ napi_value JsTextInputClientEngine::SendKeyFunction(napi_env env, napi_callback_
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 2 means JsAPI:sendKeyFunction has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "sendKeyFunction");
|
||||
}
|
||||
|
||||
napi_value JsTextInputClientEngine::DeleteForward(napi_env env, napi_callback_info info)
|
||||
@ -224,7 +224,7 @@ napi_value JsTextInputClientEngine::DeleteForward(napi_env env, napi_callback_in
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 2 means JsAPI:deleteForward has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "deleteForward");
|
||||
}
|
||||
|
||||
napi_value JsTextInputClientEngine::DeleteBackward(napi_env env, napi_callback_info info)
|
||||
@ -251,7 +251,7 @@ napi_value JsTextInputClientEngine::DeleteBackward(napi_env env, napi_callback_i
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 2 means JsAPI:deleteBackward has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "deleteBackward");
|
||||
}
|
||||
|
||||
napi_value JsTextInputClientEngine::InsertText(napi_env env, napi_callback_info info)
|
||||
@ -278,7 +278,7 @@ napi_value JsTextInputClientEngine::InsertText(napi_env env, napi_callback_info
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 2 means JsAPI:insertText has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "insertText");
|
||||
}
|
||||
|
||||
napi_value JsTextInputClientEngine::GetForward(napi_env env, napi_callback_info info)
|
||||
@ -307,7 +307,7 @@ napi_value JsTextInputClientEngine::GetForward(napi_env env, napi_callback_info
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 2 means JsAPI:getForward has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "getForward");
|
||||
}
|
||||
|
||||
napi_value JsTextInputClientEngine::GetBackward(napi_env env, napi_callback_info info)
|
||||
@ -336,7 +336,7 @@ napi_value JsTextInputClientEngine::GetBackward(napi_env env, napi_callback_info
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 2 means JsAPI:getBackward has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "getBackward");
|
||||
}
|
||||
|
||||
napi_value JsTextInputClientEngine::GetEditorAttribute(napi_env env, napi_callback_info info)
|
||||
@ -362,7 +362,7 @@ napi_value JsTextInputClientEngine::GetEditorAttribute(napi_env env, napi_callba
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 1 means JsAPI:getEditorAttribute has 1 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 1);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "getEditorAttribute");
|
||||
}
|
||||
|
||||
napi_value JsTextInputClientEngine::SelectByRange(napi_env env, napi_callback_info info)
|
||||
@ -389,7 +389,7 @@ napi_value JsTextInputClientEngine::SelectByRange(napi_env env, napi_callback_in
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 2 means JsAPI:selectByRange has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "selectByRange");
|
||||
}
|
||||
|
||||
napi_value JsTextInputClientEngine::SelectByMovement(napi_env env, napi_callback_info info)
|
||||
@ -416,7 +416,7 @@ napi_value JsTextInputClientEngine::SelectByMovement(napi_env env, napi_callback
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 2 means JsAPI:selectByMovement has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "selectByMovement");
|
||||
}
|
||||
|
||||
napi_value JsTextInputClientEngine::SendExtendAction(napi_env env, napi_callback_info info)
|
||||
@ -437,7 +437,7 @@ napi_value JsTextInputClientEngine::SendExtendAction(napi_env env, napi_callback
|
||||
ctxt->SetAction(std::move(input));
|
||||
// 2 means JsAPI:sendExtendAction has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "sendExtendAction");
|
||||
}
|
||||
|
||||
napi_value JsTextInputClientEngine::GetTextIndexAtCursor(napi_env env, napi_callback_info info)
|
||||
@ -460,7 +460,7 @@ napi_value JsTextInputClientEngine::GetTextIndexAtCursor(napi_env env, napi_call
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 1 means JsAPI:getTextIndexAtCursor has 1 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 1);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "getTextIndexAtCursor");
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
||||
|
@ -54,7 +54,7 @@ AsyncCall::~AsyncCall()
|
||||
DeleteContext(env_, context_);
|
||||
}
|
||||
|
||||
napi_value AsyncCall::Call(napi_env env, Context::ExecAction exec)
|
||||
napi_value AsyncCall::Call(napi_env env, Context::ExecAction exec, const std::string &resourceName)
|
||||
{
|
||||
if (context_ == nullptr) {
|
||||
IMSA_HILOGE("context_ is null");
|
||||
@ -73,7 +73,8 @@ napi_value AsyncCall::Call(napi_env env, Context::ExecAction exec)
|
||||
}
|
||||
napi_async_work work = context_->work;
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(env, "AsyncCall", NAPI_AUTO_LENGTH, &resource);
|
||||
std::string name = "IMF_" + resourceName;
|
||||
napi_create_string_utf8(env, name.c_str(), NAPI_AUTO_LENGTH, &resource);
|
||||
napi_create_async_work(env, nullptr, resource, AsyncCall::OnExecute, AsyncCall::OnComplete, context_, &work);
|
||||
context_->work = work;
|
||||
context_ = nullptr;
|
||||
|
@ -94,7 +94,7 @@ public:
|
||||
};
|
||||
AsyncCall(napi_env env, napi_callback_info info, std::shared_ptr<Context> context, size_t maxParamCount);
|
||||
~AsyncCall();
|
||||
napi_value Call(napi_env env, Context::ExecAction exec = nullptr);
|
||||
napi_value Call(napi_env env, Context::ExecAction exec = nullptr, const std::string &resourceName = "AsyncCall");
|
||||
napi_value SyncCall(napi_env env, Context::ExecAction exec = nullptr);
|
||||
|
||||
private:
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <set>
|
||||
|
||||
#include "input_method_controller.h"
|
||||
#include "input_method_utils.h"
|
||||
#include "js_get_input_method_textchange_listener.h"
|
||||
#include "js_util.h"
|
||||
#include "napi/native_api.h"
|
||||
@ -51,6 +52,11 @@ napi_value JsGetInputMethodController::Init(napi_env env, napi_value info)
|
||||
napi_property_descriptor descriptor[] = {
|
||||
DECLARE_NAPI_FUNCTION("getInputMethodController", GetInputMethodController),
|
||||
DECLARE_NAPI_FUNCTION("getController", GetController),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("KeyboardStatus", GetJsKeyboardStatusProperty(env)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("EnterKeyType", GetJsEnterKeyTypeProperty(env)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("TextInputType", GetJsTextInputTypeProperty(env)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("Direction", GetJsDirectionProperty(env)),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("ExtendAction", GetJsExtendActionProperty(env)),
|
||||
};
|
||||
NAPI_CALL(
|
||||
env, napi_define_properties(env, info, sizeof(descriptor) / sizeof(napi_property_descriptor), descriptor));
|
||||
@ -80,6 +86,125 @@ napi_value JsGetInputMethodController::Init(napi_env env, napi_value info)
|
||||
return info;
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodController::GetJsKeyboardStatusProperty(napi_env env)
|
||||
{
|
||||
napi_value keyboardStatus = nullptr;
|
||||
napi_value statusNone = nullptr;
|
||||
napi_value statusHide = nullptr;
|
||||
napi_value statusShow = nullptr;
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(KeyboardStatus::NONE), &statusNone));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(KeyboardStatus::HIDE), &statusHide));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(KeyboardStatus::SHOW), &statusShow));
|
||||
NAPI_CALL(env, napi_create_object(env, &keyboardStatus));
|
||||
NAPI_CALL(env, napi_set_named_property(env, keyboardStatus, "NONE", statusNone));
|
||||
NAPI_CALL(env, napi_set_named_property(env, keyboardStatus, "HIDE", statusHide));
|
||||
NAPI_CALL(env, napi_set_named_property(env, keyboardStatus, "SHOW", statusShow));
|
||||
return keyboardStatus;
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodController::GetJsEnterKeyTypeProperty(napi_env env)
|
||||
{
|
||||
napi_value enterKeyType = nullptr;
|
||||
napi_value typeUnspecified = nullptr;
|
||||
napi_value typeNone = nullptr;
|
||||
napi_value typeGo = nullptr;
|
||||
napi_value typeSearch = nullptr;
|
||||
napi_value typeSend = nullptr;
|
||||
napi_value typeNext = nullptr;
|
||||
napi_value typeDone = nullptr;
|
||||
napi_value typePrevious = nullptr;
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(EnterKeyType::UNSPECIFIED), &typeUnspecified));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(EnterKeyType::NONE), &typeNone));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(EnterKeyType::GO), &typeGo));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(EnterKeyType::SEARCH), &typeSearch));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(EnterKeyType::SEND), &typeSend));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(EnterKeyType::NEXT), &typeNext));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(EnterKeyType::DONE), &typeDone));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(EnterKeyType::PREVIOUS), &typePrevious));
|
||||
NAPI_CALL(env, napi_create_object(env, &enterKeyType));
|
||||
NAPI_CALL(env, napi_set_named_property(env, enterKeyType, "UNSPECIFIED", typeUnspecified));
|
||||
NAPI_CALL(env, napi_set_named_property(env, enterKeyType, "NONE", typeNone));
|
||||
NAPI_CALL(env, napi_set_named_property(env, enterKeyType, "GO", typeGo));
|
||||
NAPI_CALL(env, napi_set_named_property(env, enterKeyType, "SEARCH", typeSearch));
|
||||
NAPI_CALL(env, napi_set_named_property(env, enterKeyType, "SEND", typeSend));
|
||||
NAPI_CALL(env, napi_set_named_property(env, enterKeyType, "NEXT", typeNext));
|
||||
NAPI_CALL(env, napi_set_named_property(env, enterKeyType, "DONE", typeDone));
|
||||
NAPI_CALL(env, napi_set_named_property(env, enterKeyType, "PREVIOUS", typePrevious));
|
||||
return enterKeyType;
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodController::GetJsTextInputTypeProperty(napi_env env)
|
||||
{
|
||||
napi_value textInputType = nullptr;
|
||||
napi_value typeNone = nullptr;
|
||||
napi_value typeText = nullptr;
|
||||
napi_value typeMultiline = nullptr;
|
||||
napi_value typeNumber = nullptr;
|
||||
napi_value typePhone = nullptr;
|
||||
napi_value typeDatatime = nullptr;
|
||||
napi_value typeEmailAddress = nullptr;
|
||||
napi_value typeUrl = nullptr;
|
||||
napi_value typeVisiblePassword = nullptr;
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(TextInputType::NONE), &typeNone));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(TextInputType::TEXT), &typeText));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(TextInputType::MULTILINE), &typeMultiline));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(TextInputType::NUMBER), &typeNumber));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(TextInputType::PHONE), &typePhone));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(TextInputType::DATETIME), &typeDatatime));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(TextInputType::EMAIL_ADDRESS), &typeEmailAddress));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(TextInputType::URL), &typeUrl));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(TextInputType::VISIBLE_PASSWORD), &typeVisiblePassword));
|
||||
NAPI_CALL(env, napi_create_object(env, &textInputType));
|
||||
NAPI_CALL(env, napi_set_named_property(env, textInputType, "NONE", typeNone));
|
||||
NAPI_CALL(env, napi_set_named_property(env, textInputType, "TEXT", typeText));
|
||||
NAPI_CALL(env, napi_set_named_property(env, textInputType, "MULTILINE", typeMultiline));
|
||||
NAPI_CALL(env, napi_set_named_property(env, textInputType, "NUMBER", typeNumber));
|
||||
NAPI_CALL(env, napi_set_named_property(env, textInputType, "PHONE", typePhone));
|
||||
NAPI_CALL(env, napi_set_named_property(env, textInputType, "DATETIME", typeDatatime));
|
||||
NAPI_CALL(env, napi_set_named_property(env, textInputType, "EMAIL_ADDRESS", typeEmailAddress));
|
||||
NAPI_CALL(env, napi_set_named_property(env, textInputType, "URL", typeUrl));
|
||||
NAPI_CALL(env, napi_set_named_property(env, textInputType, "VISIBLE_PASSWORD", typeVisiblePassword));
|
||||
return textInputType;
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodController::GetJsDirectionProperty(napi_env env)
|
||||
{
|
||||
napi_value direction = nullptr;
|
||||
napi_value cursorUp = nullptr;
|
||||
napi_value cursorDown = nullptr;
|
||||
napi_value cursorLeft = nullptr;
|
||||
napi_value cursorRight = nullptr;
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(Direction::UP), &cursorUp));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(Direction::DOWN), &cursorDown));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(Direction::LEFT), &cursorLeft));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(Direction::RIGHT), &cursorRight));
|
||||
NAPI_CALL(env, napi_create_object(env, &direction));
|
||||
NAPI_CALL(env, napi_set_named_property(env, direction, "CURSOR_UP", cursorUp));
|
||||
NAPI_CALL(env, napi_set_named_property(env, direction, "CURSOR_DOWN", cursorDown));
|
||||
NAPI_CALL(env, napi_set_named_property(env, direction, "CURSOR_LEFT", cursorLeft));
|
||||
NAPI_CALL(env, napi_set_named_property(env, direction, "CURSOR_RIGHT", cursorRight));
|
||||
return direction;
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodController::GetJsExtendActionProperty(napi_env env)
|
||||
{
|
||||
napi_value action = nullptr;
|
||||
napi_value actionSelectAll = nullptr;
|
||||
napi_value actionCut = nullptr;
|
||||
napi_value actionCopy = nullptr;
|
||||
napi_value actionPaste = nullptr;
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(ExtendAction::SELECT_ALL), &actionSelectAll));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(ExtendAction::CUT), &actionCut));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(ExtendAction::COPY), &actionCopy));
|
||||
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(ExtendAction::PASTE), &actionPaste));
|
||||
NAPI_CALL(env, napi_create_object(env, &action));
|
||||
NAPI_CALL(env, napi_set_named_property(env, action, "SELECT_ALL", actionSelectAll));
|
||||
NAPI_CALL(env, napi_set_named_property(env, action, "CUT", actionCut));
|
||||
NAPI_CALL(env, napi_set_named_property(env, action, "COPY", actionCopy));
|
||||
NAPI_CALL(env, napi_set_named_property(env, action, "PASTE", actionPaste));
|
||||
return action;
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodController::JsConstructor(napi_env env, napi_callback_info cbinfo)
|
||||
{
|
||||
napi_value thisVar = nullptr;
|
||||
@ -301,7 +426,7 @@ napi_value JsGetInputMethodController::HandleSoftKeyboard(
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 1 means JsAPI has 1 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 1);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "handleSoftKeyboard");
|
||||
}
|
||||
|
||||
napi_status JsGetInputMethodController::ParseAttachInput(
|
||||
@ -356,7 +481,7 @@ napi_value JsGetInputMethodController::Attach(napi_env env, napi_callback_info i
|
||||
ctxt->SetAction(std::move(input));
|
||||
// 3 means JsAPI:attach has 3 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 3);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "attach");
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodController::Detach(napi_env env, napi_callback_info info)
|
||||
@ -396,7 +521,7 @@ napi_value JsGetInputMethodController::SetCallingWindow(napi_env env, napi_callb
|
||||
ctxt->SetAction(std::move(input));
|
||||
// 2 means JsAPI:setCallingWindow has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "setCallingWindow");
|
||||
}
|
||||
|
||||
napi_status JsGetInputMethodController::ParseUpdateCursorInput(
|
||||
@ -456,7 +581,7 @@ napi_value JsGetInputMethodController::UpdateCursor(napi_env env, napi_callback_
|
||||
ctxt->SetAction(std::move(input));
|
||||
// 2 means JsAPI:updateCursor has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "updateCursor");
|
||||
}
|
||||
|
||||
napi_status JsGetInputMethodController::ParseChangeSelectionInput(
|
||||
@ -495,7 +620,7 @@ napi_value JsGetInputMethodController::ChangeSelection(napi_env env, napi_callba
|
||||
ctxt->SetAction(std::move(input));
|
||||
// 4 means JsAPI:changeSelection has 4 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 4);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "changeSelection");
|
||||
}
|
||||
|
||||
napi_status JsGetInputMethodController::ParseUpdateAttributeInput(
|
||||
@ -539,7 +664,7 @@ napi_value JsGetInputMethodController::UpdateAttribute(napi_env env, napi_callba
|
||||
ctxt->SetAction(std::move(input));
|
||||
// 2 means JsAPI:updateAttribute has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "updateAttribute");
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodController::ShowSoftKeyboard(napi_env env, napi_callback_info info)
|
||||
|
@ -199,6 +199,11 @@ private:
|
||||
napi_env env, size_t argc, napi_value *argv, const std::shared_ptr<UpdateAttributeContext> &ctxt);
|
||||
static napi_status ParseUpdateCursorInput(
|
||||
napi_env env, size_t argc, napi_value *argv, const std::shared_ptr<UpdateCursorContext> &ctxt);
|
||||
static napi_value GetJsKeyboardStatusProperty(napi_env env);
|
||||
static napi_value GetJsEnterKeyTypeProperty(napi_env env);
|
||||
static napi_value GetJsTextInputTypeProperty(napi_env env);
|
||||
static napi_value GetJsDirectionProperty(napi_env env);
|
||||
static napi_value GetJsExtendActionProperty(napi_env env);
|
||||
static const std::set<std::string> TEXT_EVENT_TYPE;
|
||||
struct UvEntry {
|
||||
std::vector<std::shared_ptr<JSCallbackObject>> vecCopy;
|
||||
|
@ -202,7 +202,7 @@ napi_value JsGetInputMethodSetting::ListInputMethod(napi_env env, napi_callback_
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 1 means JsAPI:listInputMethod has 1 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 1);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "listInputMethod");
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodSetting::GetInputMethods(napi_env env, napi_callback_info info)
|
||||
@ -235,7 +235,7 @@ napi_value JsGetInputMethodSetting::GetInputMethods(napi_env env, napi_callback_
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 2 means JsAPI:getInputMethods has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "getInputMethods");
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodSetting::DisplayOptionalInputMethod(napi_env env, napi_callback_info info)
|
||||
@ -256,7 +256,7 @@ napi_value JsGetInputMethodSetting::DisplayOptionalInputMethod(napi_env env, nap
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 1 means JsAPI:displayOptionalInputMethod has 1 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 1);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "displayOptionalInputMethod");
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodSetting::ShowOptionalInputMethods(napi_env env, napi_callback_info info)
|
||||
@ -285,7 +285,7 @@ napi_value JsGetInputMethodSetting::ShowOptionalInputMethods(napi_env env, napi_
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 1 means JsAPI:showOptionalInputMethods has 1 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 1);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "showOptionalInputMethods");
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodSetting::ListInputMethodSubtype(napi_env env, napi_callback_info info)
|
||||
@ -318,7 +318,7 @@ napi_value JsGetInputMethodSetting::ListInputMethodSubtype(napi_env env, napi_ca
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 2 means JsAPI:listInputMethodSubtype has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "listInputMethodSubtype");
|
||||
}
|
||||
|
||||
napi_value JsGetInputMethodSetting::ListCurrentInputMethodSubtype(napi_env env, napi_callback_info info)
|
||||
@ -344,7 +344,7 @@ napi_value JsGetInputMethodSetting::ListCurrentInputMethodSubtype(napi_env env,
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 1 means JsAPI:listCurrentInputMethodSubtype has 1 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 1);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "listCurrentInputMethodSubtype");
|
||||
}
|
||||
|
||||
int32_t JsGetInputMethodSetting::RegisterListener(
|
||||
|
@ -241,7 +241,7 @@ napi_value JsInputMethod::SwitchInputMethod(napi_env env, napi_callback_info inf
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 2 means JsAPI:switchInputMethod has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "switchInputMethod");
|
||||
}
|
||||
|
||||
napi_value JsInputMethod::GetCurrentInputMethod(napi_env env, napi_callback_info info)
|
||||
@ -303,7 +303,7 @@ napi_value JsInputMethod::SwitchCurrentInputMethodSubtype(napi_env env, napi_cal
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 2 means JsAPI:switchCurrentInputMethodSubtype has 2 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 2);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "switchCurrentInputMethodSubtype");
|
||||
}
|
||||
|
||||
napi_value JsInputMethod::SwitchCurrentInputMethodAndSubtype(napi_env env, napi_callback_info info)
|
||||
@ -343,7 +343,7 @@ napi_value JsInputMethod::SwitchCurrentInputMethodAndSubtype(napi_env env, napi_
|
||||
ctxt->SetAction(std::move(input), std::move(output));
|
||||
// 3 means JsAPI:switchCurrentInputMethodAndSubtype has 3 params at most.
|
||||
AsyncCall asyncCall(env, info, ctxt, 3);
|
||||
return asyncCall.Call(env, exec);
|
||||
return asyncCall.Call(env, exec, "switchCurrentInputMethodAndSubtype");
|
||||
}
|
||||
} // namespace MiscServices
|
||||
} // namespace OHOS
|
@ -637,6 +637,7 @@ int32_t InputMethodAbility::CreatePanel(const std::shared_ptr<AbilityRuntime::Co
|
||||
|
||||
int32_t InputMethodAbility::DestroyPanel(const std::shared_ptr<InputMethodPanel> &inputMethodPanel)
|
||||
{
|
||||
IMSA_HILOGI("InputMethodAbility, in.");
|
||||
if (inputMethodPanel == nullptr) {
|
||||
return ErrorCode::ERROR_BAD_PARAMETERS;
|
||||
}
|
||||
|
@ -42,6 +42,13 @@ enum class Direction {
|
||||
RIGHT,
|
||||
};
|
||||
|
||||
enum class ExtendAction {
|
||||
SELECT_ALL = 0,
|
||||
CUT = 3,
|
||||
COPY,
|
||||
PASTE,
|
||||
};
|
||||
|
||||
class Configuration {
|
||||
public:
|
||||
EnterKeyType GetEnterKeyType() const
|
||||
|
@ -249,7 +249,11 @@ void InputMethodController::WorkThread()
|
||||
break;
|
||||
}
|
||||
MessageParcel *data = msg->msgContent_;
|
||||
textListener_->SendKeyboardStatus(static_cast<KeyboardStatus>(data->ReadInt32()));
|
||||
KeyboardStatus status = static_cast<KeyboardStatus>(data->ReadInt32());
|
||||
textListener_->SendKeyboardStatus(status);
|
||||
if (status == KeyboardStatus::HIDE) {
|
||||
clientInfo_.isShowKeyboard = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MSG_ID_SEND_FUNCTION_KEY: {
|
||||
@ -473,6 +477,7 @@ int32_t InputMethodController::HideCurrentInput()
|
||||
IMSA_HILOGE("proxy is nullptr");
|
||||
return ErrorCode::ERROR_EX_NULL_POINTER;
|
||||
}
|
||||
clientInfo_.isShowKeyboard = false;
|
||||
return proxy->HideCurrentInputDeprecated();
|
||||
}
|
||||
|
||||
@ -488,6 +493,7 @@ int32_t InputMethodController::ShowCurrentInput()
|
||||
IMSA_HILOGE("proxy is nullptr");
|
||||
return ErrorCode::ERROR_EX_NULL_POINTER;
|
||||
}
|
||||
clientInfo_.isShowKeyboard = true;
|
||||
return proxy->ShowCurrentInputDeprecated();
|
||||
}
|
||||
|
||||
@ -925,6 +931,7 @@ int32_t InputMethodController::ShowSoftKeyboard()
|
||||
IMSA_HILOGE("proxy is nullptr");
|
||||
return ErrorCode::ERROR_EX_NULL_POINTER;
|
||||
}
|
||||
clientInfo_.isShowKeyboard = true;
|
||||
return proxy->ShowCurrentInput();
|
||||
}
|
||||
|
||||
@ -940,6 +947,7 @@ int32_t InputMethodController::HideSoftKeyboard()
|
||||
IMSA_HILOGE("proxy is nullptr");
|
||||
return ErrorCode::ERROR_EX_NULL_POINTER;
|
||||
}
|
||||
clientInfo_.isShowKeyboard = false;
|
||||
return proxy->HideCurrentInput();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user