Lines Matching refs:env

26 napi_status KeyEventNapi::CreateKeyEvent(napi_env env, const std::shared_ptr<KeyEvent> &in, napi_value &out)
29 auto status = SetNameProperty(env, out, "action", in->GetKeyAction() - KeyEvent::KEY_ACTION_CANCEL);
34 status = SetNameProperty(env, out, "key", keyItem);
37 status = SetNameProperty(env, out, "unicodeChar", in->GetKeyItem()->GetUnicode());
41 status = SetNameProperty(env, out, "keys", keyItems);
44 status = WriteKeyStatusToJs(env, in->GetPressedKeys(), out);
47 status = WriteFunctionKeyStatusToJs(env, in, out);
51 status = SetNameProperty(env, out, "vkeyboardAction", in->GetVKeyboardAction());
54 status = SetNameProperty(env, out, "keyName", in->GetKeyName());
61 napi_status KeyEventNapi::GetKeyEvent(napi_env env, napi_value in, std::shared_ptr<KeyEvent> &out)
64 auto status = napi_typeof(env, in, &valueType);
67 KeyEvent::KeyItem item = GetNamePropertyKeyItem(env, in, "key");
70 uint32_t unicode = GetNamePropertyUint32(env, in, "unicodeChar");
73 int32_t keyAction = GetNamePropertyInt32(env, in, "action");
76 std::vector<KeyEvent::KeyItem> keyItems = GetNamePropertyKeyItems(env, in, "keys");
81 bool lock = GetNamePropertyBool(env, in, "capsLock");
83 lock = GetNamePropertyBool(env, in, "numLock");
85 lock = GetNamePropertyBool(env, in, "scrollLock");
89 int32_t vkeyboardAction = GetNamePropertyInt32(env, in, "vkeyboardAction");
92 std::string keyName = GetNamePropertyString(env, in, "keyName");
99 napi_status KeyEventNapi::CreateKeyItem(napi_env env, const std::optional<KeyEvent::KeyItem> in, napi_value &out)
101 auto status = SetNameProperty(env, out, "code", in->GetKeyCode());
104 status = SetNameProperty(env, out, "pressedTime", in->GetDownTime());
107 status = SetNameProperty(env, out, "deviceId", in->GetDeviceId());
113 napi_status KeyEventNapi::GetKeyItem(napi_env env, napi_value in, KeyEvent::KeyItem &out)
115 int32_t keyCode = GetNamePropertyInt32(env, in, "code");
117 int64_t downTime = GetNamePropertyInt64(env, in, "pressedTime");
119 int32_t deviceId = GetNamePropertyInt32(env, in, "deviceId");
124 napi_status KeyEventNapi::WriteKeyStatusToJs(napi_env env, const std::vector<int32_t> &pressedKeys, napi_value &out)
128 auto status = SetNameProperty(env, out, "ctrlKey", isExists);
133 status = SetNameProperty(env, out, "altKey", isExists);
138 status = SetNameProperty(env, out, "shiftKey", isExists);
143 status = SetNameProperty(env, out, "logoKey", isExists);
147 status = SetNameProperty(env, out, "fnKey", isExists);
153 napi_status KeyEventNapi::WriteFunctionKeyStatusToJs(napi_env env, const std::shared_ptr<KeyEvent> &in, napi_value &out)
155 auto status = SetNameProperty(env, out, "capsLock", in->GetFunctionKey(KeyEvent::CAPS_LOCK_FUNCTION_KEY));
158 status = SetNameProperty(env, out, "numLock", in->GetFunctionKey(KeyEvent::NUM_LOCK_FUNCTION_KEY));
161 status = SetNameProperty(env, out, "scrollLock", in->GetFunctionKey(KeyEvent::SCROLL_LOCK_FUNCTION_KEY));