mirror of
https://gitee.com/openharmony/accessibility
synced 2024-11-27 09:01:34 +00:00
追加inputevent的属性设定
Signed-off-by: Mupceet <laiguizhong@huawei.com>
This commit is contained in:
parent
69ef873168
commit
137940115a
@ -76,6 +76,7 @@ void ConvertActionArgsJSToNAPI(
|
||||
KeyAction TransformKeyActionValue(int32_t keyAction);
|
||||
bool HasKeyCode(const std::vector<int32_t>& pressedKeys, int32_t keyCode);
|
||||
void GetKeyValue(napi_env env, napi_value keyObject, const OHOS::MMI::KeyEvent::KeyItem* keyItem);
|
||||
void SetInputEventProperty(napi_env env, napi_value result, const std::shared_ptr<OHOS::MMI::KeyEvent> &keyEvent);
|
||||
void ConvertKeyEventToJS(napi_env env, napi_value result, const std::shared_ptr<OHOS::MMI::KeyEvent> &keyEvent);
|
||||
void ConvertCaptionPropertyToJS(napi_env env, napi_value& result,
|
||||
OHOS::AccessibilityConfig::CaptionProperty captionProperty);
|
||||
|
@ -1196,10 +1196,53 @@ void GetKeyValue(napi_env env, napi_value keyObject, const OHOS::MMI::KeyEvent::
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, keyObject, "deviceId", deviceIdValue));
|
||||
}
|
||||
|
||||
void SetInputEventProperty(napi_env env, napi_value result, const std::shared_ptr<OHOS::MMI::KeyEvent> &keyEvent)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
// set id
|
||||
napi_value idValue = nullptr;
|
||||
int32_t id = keyEvent->GetId();
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_int32(env, id, &idValue));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "id", idValue));
|
||||
|
||||
// set deviceId
|
||||
napi_value deviceIdValue = nullptr;
|
||||
int32_t deviceId = keyEvent->GetDeviceId();
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_int32(env, deviceId, &deviceIdValue));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "deviceId", deviceIdValue));
|
||||
|
||||
// set actionTime
|
||||
napi_value actionTimeValue = nullptr;
|
||||
int64_t actionTime = keyEvent->GetActionTime();
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_int64(env, actionTime, &actionTimeValue));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "actionTime", actionTimeValue));
|
||||
|
||||
// set screenId
|
||||
napi_value screenIdValue = nullptr;
|
||||
int32_t screenId = keyEvent->GetTargetDisplayId();
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_int32(env, screenId, &screenIdValue));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "screenId", screenIdValue));
|
||||
|
||||
// set windowId
|
||||
napi_value windowIdValue = nullptr;
|
||||
int32_t windowId = keyEvent->GetTargetWindowId();
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_int32(env, windowId, &windowIdValue));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, result, "windowId", windowIdValue));
|
||||
}
|
||||
|
||||
void ConvertKeyEventToJS(napi_env env, napi_value result, const std::shared_ptr<OHOS::MMI::KeyEvent> &keyEvent)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
|
||||
if (!keyEvent) {
|
||||
HILOG_ERROR("keyEvent is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
// set inputEvent
|
||||
SetInputEventProperty(env, result, keyEvent);
|
||||
|
||||
// set action
|
||||
napi_value keyActionValue = nullptr;
|
||||
KeyAction keyAction = TransformKeyActionValue(keyEvent->GetKeyAction());
|
||||
|
Loading…
Reference in New Issue
Block a user