Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
47a3a514
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
47a3a514
编写于
10月 13, 2022
作者:
H
Hollokin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
输入法错误码相关API资料补充
Signed-off-by:
N
Hollokin
<
taoyuxin2@huawei.com
>
上级
5f45cefd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
298 addition
and
224 deletion
+298
-224
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
+76
-47
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
...plication-dev/reference/apis/js-apis-inputmethodengine.md
+219
-174
zh-cn/application-dev/reference/errorcodes/errcode-InputMethodFramework.md
...-dev/reference/errorcodes/errcode-InputMethodFramework.md
+3
-3
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
浏览文件 @
47a3a514
...
...
@@ -32,8 +32,8 @@ import inputMethod from '@ohos.inputmethod';
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| packageName
<sup>
deprecated
</sup>
| string | 是 | 否 | 包名。 |
| methodId
<sup>
deprecated
</sup>
| string | 是 | 否 | Ability名。 |
| packageName
<sup>
(deprecated)
</sup>
| string | 是 | 否 | 包名。 |
| methodId
<sup>
(deprecated)
</sup>
| string | 是 | 否 | Ability名。 |
| name
<sup>
9+
</sup>
| string | 是 | 否 | 包名,非必填项。 |
| id
<sup>
9+
</sup>
| string | 是 | 否 | Ability名,非必填项。 |
| label
<sup>
9+
</sup>
| string | 是 | 否 | 输入法标签,非必填项。|
...
...
@@ -41,7 +41,7 @@ import inputMethod from '@ohos.inputmethod';
| iconId
<sup>
9+
</sup>
| number | 是 | 否 | 输入法图标id,非必填项。 |
| extra
<sup>
9+
</sup>
| object | 是 | 否 | 输入法其他信息,非必填项。 |
## inputMethod.getInputMethodController<sup>
deprecated
</sup>
## inputMethod.getInputMethodController<sup>
(deprecated)
</sup>
getInputMethodController(): InputMethodController
...
...
@@ -86,7 +86,7 @@ getController(): InputMethodController
var
InputMethodController
=
inputMethod
.
getController
();
```
## inputMethod.getInputMethodSetting<sup>
deprecated
</sup>
## inputMethod.getInputMethodSetting<sup>
(deprecated)
</sup>
getInputMethodSetting(): InputMethodSetting
...
...
@@ -169,7 +169,7 @@ try{
});
}
catch
(
err
)
{
// 捕获参数错误
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
console
.
error
(
'
switchInputMethod err:
'
+
JSON
.
stringify
(
err
)
);
}
```
## inputMethod.switchInputMethod<sup>9+</sup>
...
...
@@ -204,10 +204,10 @@ try {
console
.
error
(
'
Failed to switchInputMethod.(promise)
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
switchInputMethod promise err:
'
+
err
);
console
.
error
(
'
switchInputMethod promise err:
'
+
JSON
.
stringify
(
err
)
);
})
}
catch
(
err
)
{
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
console
.
error
(
'
switchInputMethod err:
'
+
JSON
.
stringify
(
err
)
);
}
```
...
...
@@ -268,7 +268,7 @@ try {
}
});
}
catch
(
err
)
{
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
console
.
error
(
'
switchCurrentInputMethodSubtype err:
'
+
JSON
.
stringify
(
err
)
);
}
```
...
...
@@ -303,10 +303,10 @@ try {
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype.(promise)
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
switchCurrentInputMethodSubtype
promise err:
'
+
err
);
console
.
error
(
'
switchCurrentInputMethodSubtype
err:
'
+
JSON
.
stringify
(
err
)
);
})
}
catch
(
err
)
{
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
console
.
error
(
'
switchCurrentInputMethodSubtype err:
'
+
JSON
.
stringify
(
err
)
);
}
```
...
...
@@ -353,14 +353,14 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
**示例:**
```
js
let
inputMethodProperty
=
{
packageName
:
"
com.example.kikakeyboard
"
,
methodId
:
"
ServiceExtAbility
"
}
let
inputMethodSubProperty
=
{
id
:
"
com.example.kikainput
"
,
label
:
"
ServiceExtAbility
"
}
let
inputMethodProperty
=
{
name
:
'
com.example.kikakeyboard
'
,
id
:
'
com.example.kikakeyboard
'
}
try
{
inputMethod
.
switchCurrentInputMethodAndSubtype
(
inputMethodProperty
,
inputMethodSubProperty
,
(
err
,
result
)
=>
{
if
(
err
)
{
...
...
@@ -374,7 +374,7 @@ try {
}
});
}
catch
(
err
)
{
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
console
.
error
(
'
switchCurrentInputMethodAndSubtype err:
'
+
JSON
.
stringify
(
err
)
);
}
```
...
...
@@ -398,14 +398,14 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
**示例:**
```
js
let
inputMethodProperty
=
{
packageName
:
"
com.example.kikakeyboard
"
,
methodId
:
"
ServiceExtAbility
"
}
let
inputMethodSubProperty
=
{
id
:
"
com.example.kikainput
"
,
label
:
"
ServiceExtAbility
"
}
let
inputMethodProperty
=
{
name
:
'
com.example.kikakeyboard
'
,
id
:
'
com.example.kikakeyboard
'
}
try
{
inputMethod
.
switchCurrentInputMethodAndSubtype
(
property
,
subType
).
then
((
result
)
=>
{
if
(
result
)
{
...
...
@@ -417,7 +417,7 @@ try {
console
.
error
(
'
switchCurrentInputMethodAndSubtype promise err:
'
+
err
);
})
}
catch
(
err
)
{
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
console
.
error
(
'
switchCurrentInputMethodAndSubtype promise err:
'
+
err
);
}
```
...
...
@@ -425,12 +425,17 @@ try {
下列API示例中都需使用
[
getController
](
#inputmethodgetcontroller
)
回调获取到InputMethodController实例,再通过此实例调用对应方法。
### stopInput<sup>
deprecated
</sup>
### stopInput<sup>
(deprecated)
</sup>
stopInput(callback: AsyncCallback
<
boolean
>
): void
隐藏输入法。使用callback形式返回结果。参数个数为1,否则抛出异常。
> **说明:**
> 从API version 9开始废弃, 建议使用[stopInputSession](#stopInputSession)替代
>
> 从 API version 6开始支持。
**系统能力**
:SystemCapability.MiscServices.InputMethodFramework
**参数:**
...
...
@@ -455,12 +460,17 @@ InputMethodController.stopInput((error, result) => {
});
```
### stopInput<sup>
deprecated
</sup>
### stopInput<sup>
(deprecated)
</sup>
stopInput(): Promise
<
boolean
>
隐藏输入法。使用promise形式返回结果。参数个数为0,否则抛出异常。
> **说明:**
> 从API version 9开始废弃, 建议使用[stopInputSession](#stopInputSession)替代
>
> 从 API version 6开始支持。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**返回值:**
...
...
@@ -503,7 +513,7 @@ stopInputSession(callback: AsyncCallback<boolean>): void
try
{
InputMethodController
.
stopInputSession
((
error
,
result
)
=>
{
if
(
error
)
{
console
.
error
(
'
failed to stopInputSession because
:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
stopInputSession err
:
'
+
JSON
.
stringify
(
error
));
return
;
}
if
(
result
)
{
...
...
@@ -512,8 +522,8 @@ try {
console
.
error
(
'
Failed to stopInputSession.(callback)
'
);
}
});
}
catch
(
err
)
{
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
}
catch
(
err
or
)
{
console
.
error
(
'
stopInputSession err:
'
+
JSON
.
stringify
(
error
)
);
}
```
...
...
@@ -542,10 +552,10 @@ try {
console
.
error
(
'
Failed to stopInputSession.(promise)
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
stopInputSession
promise err:
'
+
err
);
console
.
error
(
'
stopInputSession
err:
'
+
JSON
.
stringify
(
err
)
);
})
}
catch
(
err
)
{
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
console
.
error
(
'
stopInputSession err:
'
+
JSON
.
stringify
(
err
)
);
}
```
...
...
@@ -724,13 +734,13 @@ let inputMethodSubProperty = {
try
{
InputMethodSetting
.
listInputMethodSubtype
(
inputMethodSubProperty
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
listInputMethodSubtype failed
because
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
listInputMethodSubtype failed:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
listInputMethodSubtype success
'
);
});
}
catch
(
err
)
{
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
console
.
error
(
'
listInputMethodSubtype failed:
'
+
JSON
.
stringify
(
err
)
);
}
```
...
...
@@ -759,10 +769,10 @@ try {
InputMethodSetting
.
listInputMethodSubtype
(
inputMethodSubProperty
).
then
((
data
)
=>
{
console
.
info
(
'
listInputMethodSubtype success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
listInputMethodSubtype
promise err:
'
+
err
);
console
.
error
(
'
listInputMethodSubtype
err:
'
+
JSON
.
stringify
(
err
)
);
})
}
catch
(
err
)
{
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
console
.
error
(
'
listInputMethodSubtype err:
'
+
JSON
.
stringify
(
err
)
);
}
```
...
...
@@ -784,15 +794,15 @@ listCurrentInputMethodSubtype(callback: AsyncCallback<Array<InputMethodSub
```
js
try
{
InputMethodSetting
.
listCurrentInputMethodSubtype
((
err
,
data
)
=>
{
InputMethodSetting
.
listCurrentInputMethodSubtype
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
listCurrentInputMethodSubtype failed
because
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
listCurrentInputMethodSubtype failed:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
listCurrentInputMethodSubtype success
'
);
});
}
catch
(
err
)
{
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
console
.
error
(
'
listCurrentInputMethodSubtype err:
'
+
JSON
.
stringify
(
err
)
);
}
```
...
...
@@ -820,9 +830,8 @@ try {
console
.
error
(
'
listCurrentInputMethodSubtype promise err:
'
+
err
);
})
}
catch
(
err
)
{
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
console
.
error
(
'
listCurrentInputMethodSubtype err:
'
+
JSON
.
stringify
(
err
)
);
}
```
### getInputMethods<sup>9+</sup>
...
...
@@ -846,13 +855,13 @@ getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethod
try
{
InputMethodSetting
.
getInputMethods
(
true
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
getInputMethods failed
because
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
getInputMethods failed:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
getInputMethods success
'
);
});
}
catch
(
err
)
{
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
console
.
error
(
'
getInputMethods failed:
'
+
JSON
.
stringify
(
err
)
);
}
```
...
...
@@ -883,19 +892,24 @@ try {
InputMethodSetting
.
getInputMethods
(
true
).
then
((
data
)
=>
{
console
.
info
(
'
getInputMethods success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getInputMethods promise err:
'
+
err
);
console
.
error
(
'
getInputMethods promise err:
'
+
JSON
.
stringify
(
err
)
);
})
}
catch
(
err
)
{
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
console
.
error
(
'
getInputMethods promise err:
'
+
JSON
.
stringify
(
err
)
);
}
```
### listInputMethod<sup>
deprecated
</sup>
### listInputMethod<sup>
(deprecated)
</sup>
listInputMethod(callback: AsyncCallback
<
Array
<
InputMethodProperty
>>
): void
查询已安装的输入法列表。使用callback形式返回结果。参数个数为1,否则抛出异常。
> **说明:**
> 从API version 9开始废弃, 建议使用[getInputMethods](#getInputMethods)替代
>
> 从 API version 8开始支持。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**参数:**
...
...
@@ -916,12 +930,17 @@ InputMethodSetting.listInputMethod((err,data) => {
});
```
### listInputMethod<sup>
deprecated
</sup>
### listInputMethod<sup>
(deprecated)
</sup>
listInputMethod(): Promise
<
Array
<
InputMethodProperty
>>
查询已安装的输入法列表。使用promise形式返回结果。参数个数为0,否则抛出异常。
> **说明:**
> 从API version 9开始废弃, 建议使用[getInputMethods](#getInputMethods)替代
>
> 从 API version 8开始支持。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**返回值:**
...
...
@@ -936,16 +955,21 @@ listInputMethod(): Promise<Array<InputMethodProperty>>
InputMethodSetting
.
listInputMethod
().
then
((
data
)
=>
{
console
.
info
(
'
listInputMethod success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
listInputMethod promise err:
'
+
err
);
console
.
error
(
'
listInputMethod promise err:
'
+
JSON
.
stringify
(
err
)
);
})
```
### displayOptionalInputMethod<sup>
deprecated
</sup>
### displayOptionalInputMethod<sup>
(deprecated)
</sup>
displayOptionalInputMethod(callback: AsyncCallback
<
void
>
): void
显示输入法选择对话框。使用callback形式返回结果。参数个数为1,否则抛出异常。
> **说明:**
> 从API version 9开始废弃, 建议使用[showOptionalInputMethods](#showOptionalInputMethods)替代
>
> 从 API version 8开始支持。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**参数:**
...
...
@@ -988,22 +1012,27 @@ showOptionalInputMethods(callback: AsyncCallback<void>): void
try
{
InputMethodSetting
.
showOptionalInputMethods
((
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
showOptionalInputMethods failed
because
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
showOptionalInputMethods failed:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
showOptionalInputMethods success
'
);
});
}
catch
(
err
)
{
console
.
error
(
'
err:
'
+
err
.
code
+
'
err message:
'
+
err
.
message
);
console
.
error
(
'
showOptionalInputMethods failed:
'
+
JSON
.
stringify
(
err
)
);
}
```
### displayOptionalInputMethod<sup>
deprecated
</sup>
### displayOptionalInputMethod<sup>
(deprecated)
</sup>
displayOptionalInputMethod(): Promise
<
void
>
显示输入法选择对话框。使用promise形式返回结果。参数个数为0,否则抛出异常。
> **说明:**
> 从API version 9开始废弃, 建议使用[showOptionalInputMethods](#showOptionalInputMethods)替代
>
> 从 API version 8开始支持。
**系统能力**
: SystemCapability.MiscServices.InputMethodFramework
**返回值:**
...
...
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
浏览文件 @
47a3a514
...
...
@@ -51,7 +51,7 @@ import inputMethodEngine from '@ohos.inputmethodengine';
| CURSOR_RIGHT
<sup>
9+
</sup>
| number | 是 | 否 | 光标右移。 |
| WINDOW_TYPE_INPUT_METHOD_FLOAT
<sup>
9+
</sup>
| number | 是 | 否 | 输入法应用窗口风格标识。 |
## inputMethodEngine.getInputMethodEngine<a name="getInputMethodEngine"></a><sup>
deprecated
</sup>
## inputMethodEngine.getInputMethodEngine<a name="getInputMethodEngine"></a><sup>
(deprecated)
</sup>
getInputMethodEngine(): InputMethodEngine
...
...
@@ -76,7 +76,7 @@ getInputMethodEngine(): InputMethodEngine
var
InputMethodEngine
=
inputMethodEngine
.
getInputMethodEngine
();
```
## inputMethod
Ability
.getInputMethodAbility<a name="getInputMethodAbility"></a><sup>9+</sup>
## inputMethod
Engine
.getInputMethodAbility<a name="getInputMethodAbility"></a><sup>9+</sup>
getInputMethodAbility(): InputMethodAbility
...
...
@@ -96,7 +96,7 @@ getInputMethodAbility(): InputMethodAbility
var
InputMethodAbility
=
inputMethodAbility
.
getInputMethodAbility
();
```
## inputMethodEngine.createKeyboardDelegate<a name="createKeyboardDelegate"></a><sup>
deprecated
</sup>
## inputMethodEngine.createKeyboardDelegate<a name="createKeyboardDelegate"></a><sup>
(deprecated)
</sup>
createKeyboardDelegate(): KeyboardDelegate
...
...
@@ -121,7 +121,7 @@ createKeyboardDelegate(): KeyboardDelegate
var
KeyboardDelegate
=
inputMethodEngine
.
createKeyboardDelegate
();
```
## inputMethod
Ability
.getKeyboardDelegate<a name="getKeyboardDelegate"></a>
## inputMethod
Engine
.getKeyboardDelegate<a name="getKeyboardDelegate"></a>
getKeyboardDelegate(): KeyboardDelegate
...
...
@@ -163,7 +163,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli
**示例:**
```
js
InputMethodEngine
.
on
(
'
inputStart
'
,
(
kbController
,
textInputClient
)
=>
{
inputMethodEngine
.
getInputMethodEngine
()
.
on
(
'
inputStart
'
,
(
kbController
,
textInputClient
)
=>
{
KeyboardController
=
kbController
;
TextInputClient
=
textInputClient
;
});
...
...
@@ -189,7 +189,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC
**示例:**
```
js
InputMethodEngine
.
off
(
'
inputStart
'
,
(
kbController
,
textInputClient
)
=>
{
inputMethodEngine
.
getInputMethodEngine
()
.
off
(
'
inputStart
'
,
(
kbController
,
textInputClient
)
=>
{
console
.
log
(
'
delete inputStart notification.
'
);
});
```
...
...
@@ -212,7 +212,7 @@ on(type: 'inputStop', callback: () => void): void
**示例:**
```
js
I
nputMethodEngine
.
getInputMethodEngine
().
on
(
'
inputStop
'
,
()
=>
{
i
nputMethodEngine
.
getInputMethodEngine
().
on
(
'
inputStop
'
,
()
=>
{
console
.
log
(
'
inputMethodEngine inputStop
'
);
});
```
...
...
@@ -235,7 +235,7 @@ off(type: 'inputStop', callback: () => void): void
**示例:**
```
js
I
nputMethodEngine
.
getInputMethodEngine
().
off
(
'
inputStop
'
,
()
=>
{
i
nputMethodEngine
.
getInputMethodEngine
().
off
(
'
inputStop
'
,
()
=>
{
console
.
log
(
'
inputMethodEngine delete inputStop notification.
'
);
});
```
...
...
@@ -258,7 +258,7 @@ on(type: 'setCallingWindow', callback: (wid:number) => void): void
**示例:**
```
js
I
nputMethodEngine
.
getInputMethodEngine
().
on
(
'
setCallingWindow
'
,
(
wid
)
=>
{
i
nputMethodEngine
.
getInputMethodEngine
().
on
(
'
setCallingWindow
'
,
(
wid
)
=>
{
console
.
log
(
'
inputMethodEngine setCallingWindow
'
);
});
```
...
...
@@ -281,7 +281,7 @@ off(type: 'setCallingWindow', callback: (wid:number) => void): void
**示例:**
```
js
I
nputMethodEngine
.
getInputMethodEngine
().
off
(
'
setCallingWindow
'
,
()
=>
{
i
nputMethodEngine
.
getInputMethodEngine
().
off
(
'
setCallingWindow
'
,
()
=>
{
console
.
log
(
'
inputMethodEngine delete setCallingWindow notification.
'
);
});
```
...
...
@@ -304,10 +304,10 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
**示例:**
```
js
InputMethodEngine
.
on
(
'
keyboardShow
'
,
()
=>
{
inputMethodEngine
.
getInputMethodEngine
()
.
on
(
'
keyboardShow
'
,
()
=>
{
console
.
log
(
'
inputMethodEngine keyboardShow.
'
);
});
InputMethodEngine
.
on
(
'
keyboardHide
'
,
()
=>
{
inputMethodEngine
.
getInputMethodEngine
()
.
on
(
'
keyboardHide
'
,
()
=>
{
console
.
log
(
'
inputMethodEngine keyboardHide.
'
);
});
```
...
...
@@ -330,17 +330,17 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
**示例:**
```
js
InputMethodEngine
.
off
(
'
keyboardShow
'
,
()
=>
{
inputMethodEngine
.
getInputMethodEngine
()
.
off
(
'
keyboardShow
'
,
()
=>
{
console
.
log
(
'
inputMethodEngine delete keyboardShow notification.
'
);
});
InputMethodEngine
.
off
(
'
keyboardHide
'
,
()
=>
{
inputMethodEngine
.
getInputMethodEngine
()
.
off
(
'
keyboardHide
'
,
()
=>
{
console
.
log
(
'
inputMethodEngine delete keyboardHide notification.
'
);
});
```
## InputMethodAbility<a name="InputMethodAbility"></a>
下列API示例中都需使用
[
getInputMethod
Engine
](
#getInputMethodEngine
)
回调获取到InputMethodEngine
实例,再通过此实例调用对应方法。
下列API示例中都需使用
[
getInputMethod
Ability
](
#getInputMethodAbility
)
回调获取到InputMethodAbility
实例,再通过此实例调用对应方法。
### on('inputStart')<a name="inputStart"></a><sup>9+</sup>
...
...
@@ -360,7 +360,7 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient:
**示例:**
```
js
InputMethodAbility
.
on
(
'
inputStart
'
,
(
kbController
,
inputClient
)
=>
{
inputMethodEngine
.
getInputMethodAbility
()
.
on
(
'
inputStart
'
,
(
kbController
,
inputClient
)
=>
{
KeyboardController
=
kbController
;
InputClient
=
inputClient
;
});
...
...
@@ -384,7 +384,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, inputClien
**示例:**
```
js
InputMethodAbility
.
off
(
'
inputStart
'
,
(
kbController
,
inputClient
)
=>
{
inputMethodEngine
.
getInputMethodAbility
()
.
off
(
'
inputStart
'
,
(
kbController
,
inputClient
)
=>
{
console
.
log
(
'
delete inputStart notification.
'
);
});
```
...
...
@@ -407,7 +407,7 @@ on(type: 'inputStop', callback: () => void): void
**示例:**
```
js
InputMethodAbility
.
getInputMethodAbility
().
on
(
'
inputStop
'
,
()
=>
{
inputMethodEngine
.
getInputMethodAbility
().
on
(
'
inputStop
'
,
()
=>
{
console
.
log
(
'
inputMethodAbility inputStop
'
);
});
```
...
...
@@ -430,7 +430,7 @@ off(type: 'inputStop', callback: () => void): void
**示例:**
```
js
InputMethodAbility
.
getInputMethodAbility
().
off
(
'
inputStop
'
,
()
=>
{
inputMethodEngine
.
getInputMethodAbility
().
off
(
'
inputStop
'
,
()
=>
{
console
.
log
(
'
inputMethodAbility delete inputStop notification.
'
);
});
```
...
...
@@ -453,7 +453,7 @@ on(type: 'setCallingWindow', callback: (wid:number) => void): void
**示例:**
```
js
InputMethodAbility
.
getInputMethodAbility
().
on
(
'
setCallingWindow
'
,
(
wid
)
=>
{
inputMethodEngine
.
getInputMethodAbility
().
on
(
'
setCallingWindow
'
,
(
wid
)
=>
{
console
.
log
(
'
inputMethodAbility setCallingWindow
'
);
});
```
...
...
@@ -476,7 +476,7 @@ off(type: 'setCallingWindow', callback: (wid:number) => void): void
**示例:**
```
js
InputMethodAbility
.
getInputMethodAbility
().
off
(
'
setCallingWindow
'
,
()
=>
{
inputMethodEngine
.
getInputMethodAbility
().
off
(
'
setCallingWindow
'
,
()
=>
{
console
.
log
(
'
inputMethodAbility delete setCallingWindow notification.
'
);
});
```
...
...
@@ -499,10 +499,10 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
**示例:**
```
js
InputMethodAbility
.
on
(
'
keyboardShow
'
,
()
=>
{
inputMethodEngine
.
getInputMethodAbility
()
.
on
(
'
keyboardShow
'
,
()
=>
{
console
.
log
(
'
InputMethodAbility keyboardShow.
'
);
});
InputMethodAbility
.
on
(
'
keyboardHide
'
,
()
=>
{
inputMethodEngine
.
getInputMethodAbility
()
.
on
(
'
keyboardHide
'
,
()
=>
{
console
.
log
(
'
InputMethodAbility keyboardHide.
'
);
});
```
...
...
@@ -525,10 +525,10 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
**示例:**
```
js
InputMethodAbility
.
off
(
'
keyboardShow
'
,
()
=>
{
inputMethodEngine
.
getInputMethodAbility
()
.
off
(
'
keyboardShow
'
,
()
=>
{
console
.
log
(
'
InputMethodAbility delete keyboardShow notification.
'
);
});
InputMethodAbility
.
off
(
'
keyboardHide
'
,
()
=>
{
inputMethodEngine
.
getInputMethodAbility
()
.
off
(
'
keyboardHide
'
,
()
=>
{
console
.
log
(
'
InputMethodAbility delete keyboardHide notification.
'
);
});
```
...
...
@@ -551,7 +551,7 @@ on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => voi
**示例:**
```
js
InputMethodAbility
.
on
(
'
setSubtype
'
,
(
inputMethodSubtype
)
=>
{
inputMethodEngine
.
getInputMethodAbility
()
.
on
(
'
setSubtype
'
,
(
inputMethodSubtype
)
=>
{
console
.
log
(
'
InputMethodAbility setSubtype.
'
);
});
```
...
...
@@ -574,14 +574,14 @@ off(type: 'setSubtype', callback?: () => void): void
**示例:**
```
js
InputMethodAbility
.
off
(
'
setSubtype
'
,
()
=>
{
inputMethodEngine
.
getInputMethodAbility
()
.
off
(
'
setSubtype
'
,
()
=>
{
console
.
log
(
'
InputMethodAbility delete setSubtype notification.
'
);
});
```
## KeyboardDelegate<a name="KeyboardDelegate"></a>
下列API示例中都需使用
[
createKeyboardDelegate
](
#create
KeyboardDelegate
)
回调获取到KeyboardDelegate实例,再通过此实例调用对应方法。
下列API示例中都需使用
[
getKeyboardDelegate
](
#get
KeyboardDelegate
)
回调获取到KeyboardDelegate实例,再通过此实例调用对应方法。
### on('keyDown'|'keyUp')
...
...
@@ -598,17 +598,15 @@ on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void
| type | string | 是 | 设置监听类型。
<br/>
-
type为'keyDown',表示订阅硬键盘按下。
<br/>
-
type为'keyUp',表示订阅硬键盘抬起。 |
| callback |
[
KeyEvent
](
#KeyEvent
)
| 是 | 回调返回按键信息。 |
**示例:**
```
js
KeyboardDelegate
.
on
(
'
keyUp
'
,
(
keyEvent
)
=>
{
inputMethodEngine
.
getKeyboardDelegate
()
.
on
(
'
keyUp
'
,
(
keyEvent
)
=>
{
console
.
info
(
'
inputMethodEngine keyCode.(keyUp):
'
+
JSON
.
stringify
(
keyEvent
.
keyCode
));
console
.
info
(
'
inputMethodEngine keyAction.(keyUp):
'
+
JSON
.
stringify
(
keyEvent
.
keyAction
));
return
true
;
});
KeyboardDelegate
.
on
(
'
keyDown
'
,
(
keyEvent
)
=>
{
inputMethodEngine
.
getKeyboardDelegate
()
.
on
(
'
keyDown
'
,
(
keyEvent
)
=>
{
console
.
info
(
'
inputMethodEngine keyCode.(keyDown):
'
+
JSON
.
stringify
(
keyEvent
.
keyCode
));
console
.
info
(
'
inputMethodEngine keyAction.(keyDown):
'
+
JSON
.
stringify
(
keyEvent
.
keyAction
));
return
true
;
...
...
@@ -633,11 +631,11 @@ off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void
**示例:**
```
js
KeyboardDelegate
.
off
(
'
keyUp
'
,
(
keyEvent
)
=>
{
inputMethodEngine
.
getKeyboardDelegate
()
.
off
(
'
keyUp
'
,
(
keyEvent
)
=>
{
console
.
log
(
'
delete keyUp notification.
'
);
return
true
;
});
KeyboardDelegate
.
off
(
'
keyDown
'
,
(
keyEvent
)
=>
{
inputMethodEngine
.
getKeyboardDelegate
()
.
off
(
'
keyDown
'
,
(
keyEvent
)
=>
{
console
.
log
(
'
delete keyDown notification.
'
);
return
true
;
});
...
...
@@ -663,7 +661,7 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) =
**示例:**
```
js
KeyboardDelegate
.
on
(
'
cursorContextChange
'
,
(
x
,
y
,
height
)
=>
{
inputMethodEngine
.
getKeyboardDelegate
()
.
on
(
'
cursorContextChange
'
,
(
x
,
y
,
height
)
=>
{
console
.
log
(
'
inputMethodEngine cursorContextChange x:
'
+
x
);
console
.
log
(
'
inputMethodEngine cursorContextChange y:
'
+
y
);
console
.
log
(
'
inputMethodEngine cursorContextChange height:
'
+
height
);
...
...
@@ -689,7 +687,7 @@ off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number)
**示例:**
```
js
KeyboardDelegate
.
off
(
'
cursorContextChange
'
,
(
x
,
y
,
height
)
=>
{
inputMethodEngine
.
getKeyboardDelegate
()
.
off
(
'
cursorContextChange
'
,
(
x
,
y
,
height
)
=>
{
console
.
log
(
'
delete cursorContextChange notification.
'
);
});
```
...
...
@@ -711,7 +709,7 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi
**示例:**
```
js
KeyboardDelegate
.
on
(
'
selectionChange
'
,
(
oldBegin
,
oldEnd
,
newBegin
,
newEnd
)
=>
{
inputMethodEngine
.
getKeyboardDelegate
()
.
on
(
'
selectionChange
'
,
(
oldBegin
,
oldEnd
,
newBegin
,
newEnd
)
=>
{
console
.
log
(
'
inputMethodEngine beforeEach selectionChange oldBegin:
'
+
oldBegin
);
console
.
log
(
'
inputMethodEngine beforeEach selectionChange oldEnd:
'
+
oldEnd
);
console
.
log
(
'
inputMethodEngine beforeEach selectionChange newBegin:
'
+
newBegin
);
...
...
@@ -737,7 +735,7 @@ off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBe
**示例:**
```
js
KeyboardDelegate
.
off
(
'
selectionChange
'
,
(
oldBegin
,
oldEnd
,
newBegin
,
newEnd
)
=>
{
inputMethodEngine
.
getKeyboardDelegate
()
.
off
(
'
selectionChange
'
,
(
oldBegin
,
oldEnd
,
newBegin
,
newEnd
)
=>
{
console
.
log
(
'
delete selectionChange notification.
'
);
});
```
...
...
@@ -761,7 +759,7 @@ on(type: 'textChange', callback: (text: string) => void): void
**示例:**
```
js
KeyboardDelegate
.
on
(
'
textChange
'
,
(
text
)
=>
{
inputMethodEngine
.
getKeyboardDelegate
()
.
on
(
'
textChange
'
,
(
text
)
=>
{
console
.
log
(
'
inputMethodEngine textChange. text:
'
+
text
);
});
```
...
...
@@ -784,7 +782,7 @@ off(type: 'textChange', callback?: (text: string) => void): void
**示例:**
```
js
keyboardDelegate
.
off
(
'
textChange
'
,
(
text
)
=>
{
inputMethodEngine
.
getKeyboardDelegate
()
.
off
(
'
textChange
'
,
(
text
)
=>
{
console
.
log
(
'
delete textChange notification. text:
'
+
text
);
});
```
...
...
@@ -809,11 +807,10 @@ hideKeyboard(callback: AsyncCallback<void>): void
**示例:**
```
js
KeyboardController
.
hideKeyboard
((
err
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
hideKeyboard callback result---err:
'
+
err
.
msg
);
console
.
error
(
'
hideKeyboard callback result---err:
'
+
JSON
.
stringify
(
err
)
);
return
;
}
console
.
log
(
'
hideKeyboard callback.
'
);
...
...
@@ -841,7 +838,7 @@ async function InputMethodEngine() {
await
KeyboardController
.
hideKeyboard
().
then
(()
=>
{
console
.
info
(
'
hideKeyboard promise.
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
hideKeyboard promise err:
'
+
err
.
msg
);
console
.
info
(
'
hideKeyboard promise err:
'
+
JSON
.
stringify
(
err
)
);
});
}
```
...
...
@@ -850,7 +847,7 @@ async function InputMethodEngine() {
下列API示例中都需使用
[
inputStart
](
#inputStart
)
回调获取到TextInputClient实例,再通过此实例调用对应方法。
### getForward<sup>
deprecated
</sup>
### getForward<sup>
(deprecated)
</sup>
getForward(length:number, callback: AsyncCallback
<
string
>
): void
...
...
@@ -876,14 +873,14 @@ getForward(length:number, callback: AsyncCallback<string>): void
var
length
=
1
;
TextInputClient
.
getForward
(
length
,
(
err
,
text
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
getForward callback result---err:
'
+
err
.
msg
);
console
.
error
(
'
getForward callback result---err:
'
+
JSON
.
stringify
(
err
)
);
return
;
}
console
.
log
(
'
getForward callback result---text:
'
+
text
);
});
```
### getForward<sup>
deprecated
</sup>
### getForward<sup>
(deprecated)
</sup>
getForward(length:number): Promise
<
string
>
...
...
@@ -916,12 +913,12 @@ getForward(length:number): Promise<string>
await
TextInputClient
.
getForward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getForward promise result---res:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getForward promise err:
'
+
err
.
msg
);
console
.
error
(
'
getForward promise err:
'
+
JSON
.
stringify
(
err
)
);
});
}
```
### getBackward<sup>
deprecated
</sup>
### getBackward<sup>
(deprecated)
</sup>
getBackward(length:number, callback: AsyncCallback
<
string
>
): void
...
...
@@ -947,14 +944,14 @@ getBackward(length:number, callback: AsyncCallback<string>): void
var
length
=
1
;
TextInputClient
.
getBackward
(
length
,
(
err
,
text
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
getBackward callback result---err:
'
+
err
.
msg
);
console
.
error
(
'
getBackward callback result---err:
'
+
JSON
.
stringify
(
err
)
);
return
;
}
console
.
log
(
'
getBackward callback result---text:
'
+
text
);
});
```
### getBackward<sup>
deprecated
</sup>
### getBackward<sup>
(deprecated)
</sup>
getBackward(length:number): Promise
<
string
>
...
...
@@ -987,12 +984,12 @@ getBackward(length:number): Promise<string>
await
TextInputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getBackward promise result---res:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getBackward promise err:
'
+
err
.
msg
);
console
.
error
(
'
getBackward promise err:
'
+
JSON
.
stringify
(
err
)
);
});
}
```
### deleteForward<sup>
deprecated
</sup>
### deleteForward<sup>
(deprecated)
</sup>
deleteForward(length:number, callback: AsyncCallback
<
boolean
>
): void
...
...
@@ -1018,7 +1015,7 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
var
length
=
1
;
TextInputClient
.
deleteForward
(
length
,
(
err
,
result
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
deleteForward callback result---err:
'
+
err
.
msg
);
console
.
error
(
'
deleteForward callback result---err:
'
+
JSON
.
stringify
(
err
)
);
return
;
}
if
(
result
)
{
...
...
@@ -1028,7 +1025,7 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
}
});
```
### deleteForward<sup>
deprecated
</sup>
### deleteForward<sup>
(deprecated)
</sup>
deleteForward(length:number): Promise
<
boolean
>
...
...
@@ -1065,12 +1062,12 @@ async function InputMethodEngine() {
console
.
error
(
'
Failed to deleteForward.(promise)
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteForward promise err:
'
+
err
.
msg
);
console
.
error
(
'
deleteForward promise err:
'
+
JSON
.
stringify
(
err
)
);
});
}
```
### deleteBackward<sup>
deprecated
</sup>
### deleteBackward<sup>
(deprecated)
</sup>
deleteBackward(length:number, callback: AsyncCallback
<
boolean
>
): void
...
...
@@ -1096,7 +1093,7 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void
var
length
=
1
;
TextInputClient
.
deleteBackward
(
length
,
(
err
,
result
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
deleteBackward callback result---err:
'
+
err
.
msg
);
console
.
error
(
'
deleteBackward callback result---err:
'
+
JSON
.
stringify
(
err
)
);
return
;
}
if
(
result
)
{
...
...
@@ -1107,7 +1104,7 @@ TextInputClient.deleteBackward(length, (err, result) => {
});
```
### deleteBackward<sup>
deprecated
</sup>
### deleteBackward<sup>
(deprecated)
</sup>
deleteBackward(length:number): Promise
<
boolean
>
...
...
@@ -1144,11 +1141,11 @@ async function InputMethodEngine() {
console
.
error
(
'
Failed to deleteBackward.(promise)
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteBackward promise err:
'
+
err
.
msg
);
console
.
error
(
'
deleteBackward promise err:
'
+
JSON
.
stringify
(
err
)
);
});
}
```
### sendKeyFunction<sup>
deprecated
</sup>
### sendKeyFunction<sup>
(deprecated)
</sup>
sendKeyFunction(action:number, callback: AsyncCallback
<
boolean
>
): void
...
...
@@ -1173,7 +1170,7 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void
```
js
TextInputClient
.
sendKeyFunction
(
keyFunction
,
(
err
,
result
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
sendKeyFunction callback result---err:
'
+
err
.
msg
);
console
.
error
(
'
sendKeyFunction callback result---err:
'
+
JSON
.
stringify
(
err
)
);
return
;
}
if
(
result
)
{
...
...
@@ -1184,7 +1181,7 @@ TextInputClient.sendKeyFunction(keyFunction, (err, result) => {
});
```
### sendKeyFunction<sup>
deprecated
</sup>
### sendKeyFunction<sup>
(deprecated)
</sup>
sendKeyFunction(action:number): Promise
<
boolean
>
...
...
@@ -1220,12 +1217,12 @@ sendKeyFunction(action:number): Promise<boolean>
console
.
error
(
'
Failed to sendKeyFunction.(promise)
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
sendKeyFunction promise err:
'
+
err
.
msg
);
console
.
error
(
'
sendKeyFunction promise err:
'
+
JSON
.
stringify
(
err
)
);
});
}
```
### insertText<sup>
deprecated
</sup>
### insertText<sup>
(deprecated)
</sup>
insertText(text:string, callback: AsyncCallback
<
boolean
>
): void
...
...
@@ -1250,7 +1247,7 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
```
js
TextInputClient
.
insertText
(
'
test
'
,
(
err
,
result
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
insertText callback result---err:
'
+
err
.
msg
);
console
.
error
(
'
insertText callback result---err:
'
+
JSON
.
stringify
(
err
)
);
return
;
}
if
(
result
)
{
...
...
@@ -1261,7 +1258,7 @@ TextInputClient.insertText('test', (err, result) => {
});
```
### insertText<sup>
deprecated
</sup>
### insertText<sup>
(deprecated)
</sup>
insertText(text:string): Promise
<
boolean
>
...
...
@@ -1297,12 +1294,12 @@ insertText(text:string): Promise<boolean>
console
.
error
(
'
Failed to insertText.(promise)
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
insertText promise err:
'
+
err
.
msg
);
console
.
error
(
'
insertText promise err:
'
+
JSON
.
stringify
(
err
)
);
});
}
```
### getEditorAttribute<sup>
deprecated
</sup>
### getEditorAttribute<sup>
(deprecated)
</sup>
getEditorAttribute(callback: AsyncCallback
<
EditorAttribute
>
): void
...
...
@@ -1326,7 +1323,7 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
```
js
TextInputClient
.
getEditorAttribute
((
err
,
editorAttribute
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
getEditorAttribute callback result---err:
'
+
err
.
msg
);
console
.
error
(
'
getEditorAttribute callback result---err:
'
+
JSON
.
stringify
(
err
)
);
return
;
}
console
.
log
(
'
editorAttribute.inputPattern(callback):
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
...
...
@@ -1334,7 +1331,7 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
});
```
### getEditorAttribute<sup>
deprecated
</sup>
### getEditorAttribute<sup>
(deprecated)
</sup>
getEditorAttribute(): Promise
<
EditorAttribute
>
...
...
@@ -1361,7 +1358,7 @@ getEditorAttribute(): Promise<EditorAttribute>
console
.
info
(
'
editorAttribute.inputPattern(promise):
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
console
.
info
(
'
editorAttribute.enterKeyType(promise):
'
+
JSON
.
stringify
(
editorAttribute
.
enterKeyType
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
getEditorAttribute promise err:
'
+
err
.
msg
);
console
.
error
(
'
getEditorAttribute promise err:
'
+
JSON
.
stringify
(
err
)
);
});
}
```
...
...
@@ -1388,17 +1385,21 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void
**示例:**
```
js
TextInputClient
.
sendKeyFunction
(
keyFunction
,
(
err
,
result
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
sendKeyFunction callback result---err:
'
+
err
.
msg
);
return
;
}
if
(
result
)
{
console
.
info
(
'
Success to sendKeyFunction.(callback)
'
);
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.(callback)
'
);
}
});
try
{
InputClient
.
sendKeyFunction
(
keyFunction
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
sendKeyFunction err:
'
+
JSON
.
stringify
(
err
)
JSON
.
stringify
(
err
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Success to sendKeyFunction.(callback)
'
);
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.(callback)
'
);
}
});
}
catch
(
err
)
{
console
.
error
(
'
sendKeyFunction err:
'
+
JSON
.
stringify
(
err
));
}
```
### sendKeyFunction<sup>9+</sup>
...
...
@@ -1424,17 +1425,19 @@ sendKeyFunction(action:number): Promise<boolean>
**示例:**
```
js
async
function
InputMethodEngine
()
{
await
client
.
sendKeyFunction
(
keyFunction
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to sendKeyFunction.(promise)
'
);
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.(promise)
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
sendKeyFunction promise err:
'
+
err
.
msg
);
});
}
try
{
InputClient
.
sendKeyFunction
(
keyFunction
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to sendKeyFunction.(callback)
'
);
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.(callback)
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
sendKeyFunction promise err:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
console
.
error
(
'
sendKeyFunction err:
'
+
JSON
.
stringify
(
err
));
}
```
### getForward<sup>9+</sup>
...
...
@@ -1456,13 +1459,17 @@ getForward(length:number, callback: AsyncCallback<string>): void
```
js
var
length
=
1
;
TextInputClient
.
getForward
(
length
,
(
err
,
text
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
getForward callback result---err:
'
+
err
.
msg
);
return
;
}
console
.
log
(
'
getForward callback result---text:
'
+
text
);
});
try
{
InputClient
.
getForward
(
length
,
(
err
,
text
)
=>
{
if
(
err
)
{
console
.
error
(
'
getForward err:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
getForward callback result:
'
+
text
);
});
}
catch
(
err
)
{
console
.
error
(
'
getForward err:
'
+
JSON
.
stringify
(
err
));
}
```
### getForward<sup>9+</sup>
...
...
@@ -1488,13 +1495,17 @@ getForward(length:number): Promise<string>
**示例:**
```
js
async
function
InputMethod
Engine
()
{
async
function
InputMethod
Ability
()
{
var
length
=
1
;
await
TextInputClient
.
getForward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getForward promise result---res:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getForward promise err:
'
+
err
.
msg
);
});
try
{
await
InputClient
.
getForward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getForward promise resul:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getForward promise err:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
console
.
error
(
'
getForward promise err:
'
+
JSON
.
stringify
(
err
));
}
}
```
...
...
@@ -1517,13 +1528,17 @@ getBackward(length:number, callback: AsyncCallback<string>): void
```
js
var
length
=
1
;
TextInputClient
.
getBackward
(
length
,
(
err
,
text
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
getBackward callback result---err:
'
+
err
.
msg
);
return
;
}
console
.
log
(
'
getBackward callback result---text:
'
+
text
);
});
try
{
InputClient
.
getBackward
(
length
,
(
err
,
text
)
=>
{
if
(
err
)
{
console
.
error
(
'
getBackward callback result:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
getBackward callback result---text:
'
+
text
);
});
}
catch
(
err
)
{
console
.
error
(
'
getBackward callback result:
'
+
JSON
.
stringify
(
err
));
}
```
### getBackward<sup>9+</sup>
...
...
@@ -1549,13 +1564,17 @@ getBackward(length:number): Promise<string>
**示例:**
```
js
async
function
InputMethod
Engine
()
{
async
function
InputMethod
Ability
()
{
var
length
=
1
;
await
TextInputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getBackward promise result---res:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getBackward promise err:
'
+
err
.
msg
);
});
try
{
await
InputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getBackward promise result:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getBackward promise err:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
console
.
error
(
'
getBackward promise err:
'
+
JSON
.
stringify
(
err
));
}
}
```
...
...
@@ -1577,19 +1596,24 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
**示例:**
```
js
var
length
=
1
;
TextInputClient
.
deleteForward
(
length
,
(
err
,
result
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
deleteForward callback result---err:
'
+
err
.
msg
);
return
;
}
if
(
result
)
{
console
.
info
(
'
Success to deleteForward.(callback)
'
);
}
else
{
console
.
error
(
'
Failed to deleteForward.(callback)
'
);
}
});
var
length
=
1
;
try
{
InputClient
.
deleteForward
(
length
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
deleteForward callback result:
'
+
JSON
.
stringify
(
err
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Success to deleteForward.(callback)
'
);
}
else
{
console
.
error
(
'
Failed to deleteForward.(callback)
'
);
}
});
}
catch
(
err
)
{
console
.
error
(
'
deleteForward callback result:
'
+
JSON
.
stringify
(
err
));
}
```
### deleteForward<sup>9+</sup>
deleteForward(length:number): Promise
<
boolean
>
...
...
@@ -1613,17 +1637,21 @@ deleteForward(length:number): Promise<boolean>
**示例:**
```
js
async
function
InputMethod
Engine
()
{
async
function
InputMethod
Ability
()
{
var
length
=
1
;
await
TextInputClient
.
deleteForward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to deleteForward.(promise)
'
);
}
else
{
console
.
error
(
'
Failed to deleteForward.(promise)
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteForward promise err:
'
+
err
.
msg
);
});
try
{
await
InputClient
.
deleteForward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to deleteForward.(promise)
'
);
}
else
{
console
.
error
(
'
Failed to deleteForward.(promise)
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteForward promise err:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
console
.
error
(
'
deleteForward promise err:
'
+
JSON
.
stringify
(
err
));
}
}
```
...
...
@@ -1646,9 +1674,9 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void
```
js
var
length
=
1
;
Text
InputClient
.
deleteBackward
(
length
,
(
err
,
result
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
deleteBackward
callback result---err:
'
+
err
.
msg
);
InputClient
.
deleteBackward
(
length
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
deleteBackward
err:
'
+
JSON
.
stringify
(
err
)
);
return
;
}
if
(
result
)
{
...
...
@@ -1691,7 +1719,7 @@ async function InputMethodAbility() {
console
.
error
(
'
Failed to deleteBackward.(promise)
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteBackward promise err:
'
+
err
.
msg
);
console
.
error
(
'
deleteBackward promise err:
'
+
JSON
.
stringify
(
err
)
);
});
}
```
...
...
@@ -1714,9 +1742,9 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
**示例:**
```
js
Text
InputClient
.
insertText
(
'
test
'
,
(
err
,
result
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
insertText
callback result---err:
'
+
err
.
msg
);
InputClient
.
insertText
(
'
test
'
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
insertText
err:
'
+
JSON
.
stringify
(
err
)
);
return
;
}
if
(
result
)
{
...
...
@@ -1750,16 +1778,20 @@ insertText(text:string): Promise<boolean>
**示例:**
```
js
async
function
InputMethodEngine
()
{
await
TextInputClient
.
insertText
(
'
test
'
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to insertText.(promise)
'
);
}
else
{
console
.
error
(
'
Failed to insertText.(promise)
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
insertText promise err:
'
+
err
.
msg
);
});
async
function
InputMethodAbility
()
{
try
{
await
InputClient
.
insertText
(
'
test
'
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to insertText.(promise)
'
);
}
else
{
console
.
error
(
'
Failed to insertText.(promise)
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
insertText promise err:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
e
)
{
console
.
error
(
'
insertText promise err:
'
+
JSON
.
stringify
(
err
));
}
}
```
...
...
@@ -1780,9 +1812,9 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
**示例:**
```
js
Text
InputClient
.
getEditorAttribute
((
err
,
editorAttribute
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
getEditorAttribute callback result---err:
'
+
err
.
msg
);
InputClient
.
getEditorAttribute
((
err
,
editorAttribute
)
=>
{
if
(
err
)
{
console
.
error
(
'
getEditorAttribute callback result---err:
'
+
JSON
.
stringify
(
err
)
);
return
;
}
console
.
log
(
'
editorAttribute.inputPattern(callback):
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
...
...
@@ -1808,11 +1840,11 @@ getEditorAttribute(): Promise<EditorAttribute>
```
js
async
function
InputMethodEngine
()
{
await
Text
InputClient
.
getEditorAttribute
().
then
((
editorAttribute
)
=>
{
await
InputClient
.
getEditorAttribute
().
then
((
editorAttribute
)
=>
{
console
.
info
(
'
editorAttribute.inputPattern(promise):
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
console
.
info
(
'
editorAttribute.enterKeyType(promise):
'
+
JSON
.
stringify
(
editorAttribute
.
enterKeyType
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
getEditorAttribute promise err:
'
+
err
.
msg
);
console
.
error
(
'
getEditorAttribute promise err:
'
+
JSON
.
stringify
(
err
)
);
});
}
```
...
...
@@ -1835,12 +1867,17 @@ moveCursor(direction: number, callback: AsyncCallback<void>): void
**示例:**
```
js
InputClient
.
moveCursor
(
inputMethodAbility
.
CURSOR_xxx
,
(
err
)
=>
{
if
(
err
===
undefined
)
{
console
.
error
(
'
moveCursor callback result---err:
'
+
err
.
msg
);
return
;
}
});
try
{
InputClient
.
moveCursor
(
inputMethodAbility
.
CURSOR_xxx
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
moveCursor err:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
moveCursor success
'
);
});
}
catch
(
err
)
{
console
.
error
(
'
moveCursor err:
'
+
JSON
.
stringify
(
err
));
}
```
### moveCursor<sup>9+</sup>
...
...
@@ -1867,11 +1904,19 @@ moveCursor(direction: number): Promise<void>
```
js
async
function
InputMethodAbility
()
{
await
InputClient
.
moveCursor
(
inputMethodAbility
.
CURSOR_xxx
).
then
(
async
(
err
)
=>
{
console
.
log
(
'
moveCursor success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
moveCursor success err:
'
+
err
.
msg
);
});
try
{
await
InputClient
.
moveCursor
(
inputMethodEngine
.
CURSOR_xxx
).
then
((
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
moveCursor err:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
moveCursor success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
moveCursor success err:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
e
)
{
console
.
log
(
'
moveCursor err:
'
+
JSON
.
stringify
(
err
));
}
}
```
...
...
zh-cn/application-dev/reference/errorcodes/errcode-InputMethodFramework.md
浏览文件 @
47a3a514
# 输入法框架错误码
##
12800
201 权限校验异常
## 201 权限校验异常
### 错误信息
the permissions check fails.
...
...
@@ -11,7 +11,7 @@ the permissions check fails.
### 处理步骤
给应用配置相应的权限
##
12800
401 参数校验异常
## 401 参数校验异常
### 错误信息
the parameters check fails.
...
...
@@ -22,7 +22,7 @@ the parameters check fails.
### 处理步骤
修改接口调用时传入的参数个数或者类型
##
12800
801 功能支持异常
## 801 功能支持异常
### 错误信息
call unsupported api.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录