修改GetEditorAttributeSync接口

Signed-off-by: guojin31 <guojin31@huawei.com>
This commit is contained in:
guojin31 2023-12-04 17:09:37 +08:00
parent d5701d4ee2
commit e3c82f6726
3 changed files with 8 additions and 4 deletions

View File

@ -159,7 +159,6 @@ napi_value JsKeyboardDelegateSetting::GetKDInstance(napi_env env, napi_callback_
IMSA_HILOGE("napi_get_reference_value(env, KDSRef_, &cons) != napi_ok");
return nullptr;
}
IMSA_HILOGE("Get a reference to the global variable appAccountRef_ complete");
if (napi_new_instance(env, cons, 0, nullptr, &instance) != napi_ok) {
IMSA_HILOGE("napi_new_instance(env, cons, 0, nullptr, &instance) != napi_ok");
return nullptr;

View File

@ -568,7 +568,7 @@ napi_value JsTextInputClientEngine::GetEditorAttributeSync(napi_env env, napi_ca
}
IMSA_HILOGD("patternCode: %{public}d", inputPattern);
const InputAttribute attribute = { .inputPattern = enterKeyType, .enterKeyType = inputPattern };
const InputAttribute attribute = { .inputPattern = inputPattern, .enterKeyType = enterKeyType };
return JsUtils::GetValue(env, attribute);
}

View File

@ -193,11 +193,16 @@ export class KeyboardController {
}
}
getAttributeSync() {
async getAttributeSync() {
try {
let editAttribute = globalThis.textInputClient.getEditorAttributeSync();
let editAttribute1 = await globalThis.textInputClient.getEditorAttribute();
this.addLog(`[inputDemo] publish getEditorAttributeSync editAttribute= ${JSON.stringify(editAttribute)}`);
this.publishCommonEvent('getEditorAttributeSyncResult', TEST_RESULT_CODE.SUCCESS);
if(editAttribute.inputPattern == editAttribute1.inputPattern && editAttribute.enterKeyType == editAttribute1.enterKeyType) {
this.publishCommonEvent('getEditorAttributeSyncResult', TEST_RESULT_CODE.SUCCESS);
} else{
this.publishCommonEvent('getEditorAttributeSyncResult', TEST_RESULT_CODE.FAILED);
}
} catch (err) {
this.publishCommonEvent('getEditorAttributeSyncResult', TEST_RESULT_CODE.FAILED);
}