Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
f6c137f2
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
提交
f6c137f2
编写于
12月 12, 2022
作者:
H
Hollokin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed
17f57a91
from
https://gitee.com/hollokin/docs/pulls/12415
【输入法框架】API资料优化 Signed-off-by:
N
Hollokin
<
taoyuxin2@huawei.com
>
上级
ca1a9d53
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
349 addition
and
333 deletion
+349
-333
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
+205
-183
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
...plication-dev/reference/apis/js-apis-inputmethodengine.md
+144
-150
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
浏览文件 @
f6c137f2
...
...
@@ -31,14 +31,14 @@ import inputMethod from '@ohos.inputmethod';
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| name
<sup>
9+
</sup>
| string | 是 | 否 | 输入法内部名称。
|
| id
<sup>
9+
</sup>
| string | 是 | 否 | 输入法唯一标识。
|
| label
<sup>
9+
</sup>
| string | 是 | 否 | 输入法对外显示名称。 |
| icon
<sup>
9+
</sup>
| string | 是 | 否 | 输入法图标数据。 |
| iconId
<sup>
9+
</sup>
| number | 是 | 否 | 输入法图标资源号。 |
| extra
<sup>
9+
</sup>
| object | 是 |
否 | 输入法扩展信息。
|
| packageName
<sup>
(deprecated)
</sup>
| string | 是 | 否 | 输入法包名。
<br/>
**说明:**
从API version 8开始支持,从API version 9开始废弃,建议使用name替代。 |
| methodId
<sup>
(deprecated)
</sup>
| string | 是 | 否 | 输入法唯一标识。
<br/>
**说明:**
从API version 8开始支持,从API version 9开始废弃,建议使用id替代。 |
| name
<sup>
9+
</sup>
| string | 是 | 否 | 输入法内部名称。
必填。
|
| id
<sup>
9+
</sup>
| string | 是 | 否 | 输入法唯一标识。
必填。
|
| label
<sup>
9+
</sup>
| string | 是 | 否 | 输入法对外显示名称。
非必填。
|
| icon
<sup>
9+
</sup>
| string | 是 | 否 | 输入法图标数据。
非必填。
|
| iconId
<sup>
9+
</sup>
| number | 是 | 否 | 输入法图标资源号。
非必填。
|
| extra
<sup>
9+
</sup>
| object | 是 |
是 | 输入法扩展信息。 必填。
|
| packageName
<sup>
(deprecated)
</sup>
| string | 是 | 否 | 输入法包名。
必填。
<br/>
**说明:**
从API version 8开始支持,从API version 9开始废弃,建议使用name替代。 |
| methodId
<sup>
(deprecated)
</sup>
| string | 是 | 否 | 输入法唯一标识。
必填。
<br/>
**说明:**
从API version 8开始支持,从API version 9开始废弃,建议使用id替代。 |
## inputMethod.getController<sup>9+</sup>
...
...
@@ -102,7 +102,7 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolea
切换输入法。使用callback异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -120,25 +120,33 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolea
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
let
im
=
inputMethod
.
getCurrentInputMethod
();
let
prop
=
{
packageName
:
im
.
packageName
,
methodId
:
im
.
methodId
,
name
:
im
.
packageName
,
id
:
im
.
methodId
,
extra
:
{}
}
try
{
inputMethod
.
switchInputMethod
(
{
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
,
extra
:
{}}
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
switchInputMethod err
:
'
+
JSON
.
stringify
(
err
));
inputMethod
.
switchInputMethod
(
prop
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to switchInputMethod
:
'
+
JSON
.
stringify
(
err
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succe
ss to switchInputMethod.(callback)
'
);
console
.
info
(
'
Succe
eded in switching inputmethod.
'
);
}
else
{
console
.
error
(
'
Failed to switchInputMethod.
(callback)
'
);
console
.
error
(
'
Failed to switchInputMethod.
'
);
}
});
}
catch
(
err
)
{
console
.
error
(
'
switchInputMethod err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to switchInputMethod
:
'
+
JSON
.
stringify
(
err
));
}
```
## inputMethod.switchInputMethod<sup>9+</sup>
...
...
@@ -146,7 +154,7 @@ switchInputMethod(target: InputMethodProperty): Promise<boolean>
切换输入法。使用promise异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -169,23 +177,31 @@ switchInputMethod(target: InputMethodProperty): Promise<boolean>
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
let
im
=
inputMethod
.
getCurrentInputMethod
();
let
prop
=
{
packageName
:
im
.
packageName
,
methodId
:
im
.
methodId
,
name
:
im
.
packageName
,
id
:
im
.
methodId
,
extra
:
{}
}
try
{
inputMethod
.
switchInputMethod
(
{
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
,
extra
:
{}}
).
then
((
result
)
=>
{
inputMethod
.
switchInputMethod
(
prop
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succe
ss to switchInputM
ethod.
'
);
console
.
info
(
'
Succe
eded in switching inputm
ethod.
'
);
}
else
{
console
.
error
(
'
Failed to switchInputMethod.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
switchInputMethod err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to switchInputMethod
:
'
+
JSON
.
stringify
(
err
));
})
}
catch
(
err
)
{
console
.
error
(
'
switchInputMethod err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to switchInputMethod
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -215,7 +231,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb
在当前输入法应用内切换子类型。使用callback异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -233,36 +249,35 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
let
inputMethodSubtype
=
{
id
:
"
com.example.kikakeyboard
"
,
label
:
"
ServiceExtAbility
"
,
name
:
""
,
mode
:
"
upper
"
,
locale
:
""
,
language
:
""
,
icon
:
""
,
iconId
:
0
,
extra
:
{}
}
try
{
inputMethod
.
switchCurrentInputMethodSubtype
(
inputMethodSubtype
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
switchCurrentInputMethodSubtype err:
'
+
JSON
.
stringify
(
err
));
inputMethod
.
switchCurrentInputMethodSubtype
({
id
:
"
com.example.kikakeyboard
"
,
label
:
"
ServiceExtAbility
"
,
name
:
""
,
mode
:
"
upper
"
,
locale
:
""
,
language
:
""
,
icon
:
""
,
iconId
:
0
,
extra
:
{}
},
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype:
'
+
JSON
.
stringify
(
err
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succe
ss to switchCurrentInputMethodSubtype.(callback)
'
);
console
.
info
(
'
Succe
eded in switching currentInputMethodSubtype.
'
);
}
else
{
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype
.(callback)
'
);
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype
'
);
}
});
}
catch
(
err
)
{
console
.
error
(
'
switchCurrentInputMethodSubtype err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -272,7 +287,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise<boolean&
在当前输入法应用内切换子类型。使用promise异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -295,34 +310,33 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise<boolean&
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
let
inputMethodSubtype
=
{
id
:
"
com.example.kikakeyboard
"
,
label
:
"
ServiceExtAbility
"
,
name
:
""
,
mode
:
"
upper
"
,
locale
:
""
,
language
:
""
,
icon
:
""
,
iconId
:
0
,
extra
:
{}
}
try
{
inputMethod
.
switchCurrentInputMethodSubtype
(
inputMethodSubtype
).
then
((
result
)
=>
{
inputMethod
.
switchCurrentInputMethodSubtype
({
id
:
"
com.example.kikakeyboard
"
,
label
:
"
ServiceExtAbility
"
,
name
:
""
,
mode
:
"
upper
"
,
locale
:
""
,
language
:
""
,
icon
:
""
,
iconId
:
0
,
extra
:
{}
}).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succe
ss to switchC
urrentInputMethodSubtype.
'
);
console
.
info
(
'
Succe
eded in switching c
urrentInputMethodSubtype.
'
);
}
else
{
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
switchCurrentInputMethodSubtype err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype
:
'
+
JSON
.
stringify
(
err
));
})
}
catch
(
err
)
{
console
.
error
(
'
switchCurrentInputMethodSubtype err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to switchCurrentInputMethodSubtype
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -352,7 +366,7 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
切换至指定输入法应用的指定子类型,用于跨输入法应用切换子类型。使用callback异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -371,41 +385,43 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
let
im
=
inputMethod
.
getCurrentInputMethod
();
let
inputMethodProperty
=
{
packageName
:
"
com.example.kikakeyboard
"
,
methodId
:
"
ServiceExtAbility
"
,
extra
:
{}
}
let
inputMethodSubProperty
=
{
id
:
"
com.example.kikakeyboard
"
,
label
:
"
ServiceExtAbility
"
,
name
:
""
,
mode
:
"
upper
"
,
locale
:
""
,
language
:
""
,
icon
:
""
,
iconId
:
0
,
packageName
:
im
.
packageName
,
methodId
:
im
.
methodId
,
name
:
im
.
packageName
,
id
:
im
.
methodId
,
extra
:
{}
}
try
{
inputMethod
.
switchCurrentInputMethodAndSubtype
(
inputMethodProperty
,
inputMethodSubProperty
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
switchCurrentInputMethodAndSubtype err:
'
+
JSON
.
stringify
(
err
));
inputMethod
.
switchCurrentInputMethodAndSubtype
(
inputMethodProperty
,
{
id
:
"
com.example.kikakeyboard
"
,
label
:
"
ServiceExtAbility
"
,
name
:
""
,
mode
:
"
upper
"
,
locale
:
""
,
language
:
""
,
icon
:
""
,
iconId
:
0
,
extra
:
{}
},
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype:
'
+
JSON
.
stringify
(
err
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succe
ss to switchCurrentInputMethodAndSubtype.(callback)
'
);
console
.
info
(
'
Succe
eded in switching currentInputMethodAndSubtype.
'
);
}
else
{
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype.
(callback)
'
);
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype.
'
);
}
});
}
catch
(
err
)
{
console
.
error
(
'
switchCurrentInputMethodAndSubtype err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -415,7 +431,7 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
切换至指定输入法应用的指定子类型,用于跨输入法应用切换子类型。使用promise异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -439,39 +455,41 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800005 | Configuration persisting error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
let
im
=
inputMethod
.
getCurrentInputMethod
();
let
inputMethodProperty
=
{
packageName
:
"
com.example.kikakeyboard
"
,
methodId
:
"
ServiceExtAbility
"
,
extra
:
{}
}
let
inputMethodSubProperty
=
{
id
:
"
com.example.kikakeyboard
"
,
label
:
"
ServiceExtAbility
"
,
name
:
""
,
mode
:
"
upper
"
,
locale
:
""
,
language
:
""
,
icon
:
""
,
iconId
:
0
,
packageName
:
im
.
packageName
,
methodId
:
im
.
methodId
,
name
:
im
.
packageName
,
id
:
im
.
methodId
,
extra
:
{}
}
try
{
inputMethod
.
switchCurrentInputMethodAndSubtype
(
inputMethodProperty
,
inputMethodSubProperty
).
then
((
result
)
=>
{
inputMethod
.
switchCurrentInputMethodAndSubtype
(
inputMethodProperty
,
{
id
:
im
.
packageName
,
label
:
im
.
methodId
,
name
:
""
,
mode
:
"
upper
"
,
locale
:
""
,
language
:
""
,
icon
:
""
,
iconId
:
0
,
extra
:
{}
}).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succe
ss to switchC
urrentInputMethodAndSubtype.
'
);
console
.
info
(
'
Succe
eded in switching c
urrentInputMethodAndSubtype.
'
);
}
else
{
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
switchCurrentInputMethodAndSubtype err:
'
+
err
);
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype:
'
+
JSON
.
stringify
(
err
)
);
})
}
catch
(
err
)
{
console
.
error
(
'
switchCurrentInputMethodAndSubtype err:
'
+
err
);
console
.
error
(
'
Failed to switchCurrentInputMethodAndSubtype:
'
+
JSON
.
stringify
(
err
)
);
}
```
...
...
@@ -548,25 +566,25 @@ stopInputSession(callback: AsyncCallback<boolean>): void
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
try
{
inputMethodController
.
stopInputSession
((
error
,
result
)
=>
{
if
(
error
)
{
console
.
error
(
'
stopInputSession err
:
'
+
JSON
.
stringify
(
error
));
if
(
error
!==
undefined
)
{
console
.
error
(
'
Failed to stopInputSession
:
'
+
JSON
.
stringify
(
error
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succe
ss to stopInputSession.(callback)
'
);
console
.
info
(
'
Succe
eded in stopping inputSession.
'
);
}
else
{
console
.
error
(
'
Failed to stopInputSession.
(callback)
'
);
console
.
error
(
'
Failed to stopInputSession.
'
);
}
});
}
catch
(
error
)
{
console
.
error
(
'
stopInputSession err
:
'
+
JSON
.
stringify
(
error
));
console
.
error
(
'
Failed to stopInputSession
:
'
+
JSON
.
stringify
(
error
));
}
```
...
...
@@ -591,7 +609,7 @@ stopInputSession(): Promise<boolean>
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
...
...
@@ -599,15 +617,15 @@ stopInputSession(): Promise<boolean>
try
{
inputMethodController
.
stopInputSession
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succe
ss to stopI
nputSession.
'
);
console
.
info
(
'
Succe
eded in stopping i
nputSession.
'
);
}
else
{
console
.
error
(
'
Failed to stopInputSession.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
stopInputSession err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to stopInputSession
:
'
+
JSON
.
stringify
(
err
));
})
}
catch
(
err
)
{
console
.
error
(
'
stopInputSession err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to stopInputSession
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -617,7 +635,7 @@ showSoftKeyboard(callback: AsyncCallback<void>): void
显示软键盘。需要与输入框绑定使用。当点击输入框后,才可通过该接口的调用显示出当前输入法的软键盘。使用callback异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -634,16 +652,16 @@ showSoftKeyboard(callback: AsyncCallback<void>): void
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
inputMethodController
.
showSoftKeyboard
((
err
)
=>
{
if
(
err
===
undefined
)
{
console
.
info
(
'
showSoftKeyboard success
'
);
console
.
info
(
'
Succeeded in showing softKeyboard.
'
);
}
else
{
console
.
error
(
'
showSoftKeyboard failed because
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to showSoftKeyboard
:
'
+
JSON
.
stringify
(
err
));
}
})
```
...
...
@@ -654,7 +672,7 @@ showSoftKeyboard(): Promise<void>
显示软键盘。需要与输入框绑定使用。当点击输入框后,才可通过该接口的调用显示出当前输入法的软键盘。使用Promise异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -671,15 +689,15 @@ showSoftKeyboard(): Promise<void>
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
inputMethodController
.
showSoftKeyboard
().
then
(
async
(
err
)
=>
{
console
.
log
(
'
showSoftKeyboard success
'
);
inputMethodController
.
showSoftKeyboard
().
then
(
(
)
=>
{
console
.
log
(
'
Succeeded in showing softKeyboard.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
showSoftKeyboard err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to showSoftKeyboard
:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -689,7 +707,7 @@ hideSoftKeyboard(callback: AsyncCallback<void>): void
隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用callback异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -706,16 +724,16 @@ hideSoftKeyboard(callback: AsyncCallback<void>): void
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
inputMethodController
.
hideSoftKeyboard
((
err
)
=>
{
if
(
err
===
undefined
)
{
console
.
info
(
'
hideSoftKeyboard success
'
);
console
.
info
(
'
Succeeded in hiding softKeyboard.
'
);
}
else
{
console
.
error
(
'
hideSoftKeyboard failed because
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to hideSoftKeyboard
:
'
+
JSON
.
stringify
(
err
));
}
})
```
...
...
@@ -726,7 +744,7 @@ hideSoftKeyboard(): Promise<void>
隐藏软键盘。需要与输入框绑定使用。点击输入框后,才可以使用该接口的调用隐藏软键盘。使用Promise异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -743,15 +761,15 @@ hideSoftKeyboard(): Promise<void>
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800003 | Input method client error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
inputMethodController
.
hideSoftKeyboard
().
then
(
async
(
err
)
=>
{
console
.
log
(
'
hideSoftKeyboard success
'
);
inputMethodController
.
hideSoftKeyboard
().
then
(
(
)
=>
{
console
.
log
(
'
Succeeded in hiding softKeyboard.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
hideSoftKeyboard err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to hideSoftKeyboard
:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -777,14 +795,14 @@ stopInput(callback: AsyncCallback<boolean>): void
```
js
inputMethodController
.
stopInput
((
error
,
result
)
=>
{
if
(
error
)
{
console
.
error
(
'
failed to stopInput because
:
'
+
JSON
.
stringify
(
error
));
if
(
error
!==
undefined
)
{
console
.
error
(
'
Failed to stopInput
:
'
+
JSON
.
stringify
(
error
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succe
ss to stopInput.(callback)
'
);
console
.
info
(
'
Succe
eded in stopping input.
'
);
}
else
{
console
.
error
(
'
Failed to stopInput.
(callback)
'
);
console
.
error
(
'
Failed to stopInput.
'
);
}
});
```
...
...
@@ -812,12 +830,12 @@ stopInput(): Promise<boolean>
```
js
inputMethodController
.
stopInput
().
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succe
ss to stopI
nput.
'
);
console
.
info
(
'
Succe
eded in stopping i
nput.
'
);
}
else
{
console
.
error
(
'
Failed to stopInput.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
stopInput err
:
'
+
err
);
console
.
error
(
'
Failed to stopInput
:
'
+
err
);
})
```
...
...
@@ -891,26 +909,28 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
let
inputMethodProperty
=
{
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
,
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
,
name
:
'
com.example.kikakeyboard
'
,
id
:
'
com.example.kikakeyboard
'
,
extra
:{}
}
try
{
inputMethodSetting
.
listInputMethodSubtype
(
inputMethodProperty
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
listInputMethodSubtype failed
:
'
+
JSON
.
stringify
(
err
));
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to listInputMethodSubtype
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
listInputMethodSubtype success
'
);
console
.
log
(
'
Succeeded in listing inputMethodSubtype.
'
);
});
}
catch
(
err
)
{
console
.
error
(
'
listInputMethodSubtype failed
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to listInputMethodSubtype
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -941,24 +961,26 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<Arr
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
let
inputMethodProperty
=
{
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
,
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
,
name
:
'
com.example.kikakeyboard
'
,
id
:
'
com.example.kikakeyboard
'
,
extra
:{}
}
try
{
inputMethodSetting
.
listInputMethodSubtype
(
inputMethodProperty
).
then
((
data
)
=>
{
console
.
info
(
'
listInputMethodSubtype success
'
);
console
.
info
(
'
Succeeded in listing inputMethodSubtype.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
listInputMethodSubtype err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to listInputMethodSubtype
:
'
+
JSON
.
stringify
(
err
));
})
}
catch
(
err
)
{
console
.
error
(
'
listInputMethodSubtype err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to listInputMethodSubtype
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -983,21 +1005,21 @@ listCurrentInputMethodSubtype(callback: AsyncCallback<Array<InputMethodSub
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
try
{
inputMethodSetting
.
listCurrentInputMethodSubtype
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
listCurrentInputMethodSubtype failed
:
'
+
JSON
.
stringify
(
err
));
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to listCurrentInputMethodSubtype
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
listCurrentInputMethodSubtype success
'
);
console
.
log
(
'
Succeeded in listing currentInputMethodSubtype.
'
);
});
}
catch
(
err
)
{
console
.
error
(
'
listCurrentInputMethodSubtype err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to listCurrentInputMethodSubtype
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1022,19 +1044,19 @@ listCurrentInputMethodSubtype(): Promise<Array<InputMethodSubtype>>
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
try
{
inputMethodSetting
.
listCurrentInputMethodSubtype
().
then
((
data
)
=>
{
console
.
info
(
'
listCurrentInputMethodSubtype success
'
);
console
.
info
(
'
Succeeded in listing currentInputMethodSubtype.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
listCurrentInputMethodSubtype err:
'
+
err
);
console
.
error
(
'
Failed to listCurrentInputMethodSubtype:
'
+
JSON
.
stringify
(
err
)
);
})
}
catch
(
err
)
{
console
.
error
(
'
listCurrentInputMethodSubtype err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to listCurrentInputMethodSubtype
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1060,21 +1082,21 @@ getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethod
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
try
{
inputMethodSetting
.
getInputMethods
(
true
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
getInputMethods failed
:
'
+
JSON
.
stringify
(
err
));
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to getInputMethods
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
getInputMethods success
'
);
console
.
log
(
'
Succeeded in getting inputMethods.
'
);
});
}
catch
(
err
)
{
console
.
error
(
'
getInputMethods failed
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to getInputMethods
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1099,7 +1121,7 @@ getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>>
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800001 | Package manager error. |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**返回值:**
...
...
@@ -1112,12 +1134,12 @@ getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>>
```
js
try
{
inputMethodSetting
.
getInputMethods
(
true
).
then
((
data
)
=>
{
console
.
info
(
'
getInputMethods success
'
);
console
.
info
(
'
Succeeded in getting inputMethods.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getInputMethods err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to getInputMethods
:
'
+
JSON
.
stringify
(
err
));
})
}
catch
(
err
)
{
console
.
error
(
'
getInputMethods err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to getInputMethods
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1127,7 +1149,7 @@ showOptionalInputMethods(callback: AsyncCallback<boolean>): void
显示输入法选择对话框。使用callback异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -1143,21 +1165,21 @@ showOptionalInputMethods(callback: AsyncCallback<boolean>): void
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
try
{
inputMethodSetting
.
showOptionalInputMethods
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
showOptionalInputMethods failed
:
'
+
JSON
.
stringify
(
err
));
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to showOptionalInputMethods
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
showOptionalInputMethods success
'
);
console
.
info
(
'
Succeeded in showing optionalInputMethods.
'
);
});
}
catch
(
err
)
{
console
.
error
(
'
showOptionalInputMethods failed
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to showOptionalInputMethods
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1167,7 +1189,7 @@ showOptionalInputMethods(): Promise<boolean>
显示输入法选择对话框。使用promise异步回调。
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
**需要权限:**
ohos.permission.CONNECT_IME_ABILITY
,仅系统应用可用。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -1183,15 +1205,15 @@ showOptionalInputMethods(): Promise<boolean>
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800008 | Input method
settings extension
error. |
| 12800008 | Input method
manager service
error. |
**示例:**
```
js
inputMethodSetting
.
showOptionalInputMethods
().
then
((
data
)
=>
{
console
.
info
(
'
displayOptionalInputMethod succes
s.
'
);
console
.
info
(
'
Succeeded in showing optionalInputMethod
s.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
displayOptionalInputMethod err:
'
+
err
);
console
.
error
(
'
Failed to showOptionalInputMethods:
'
+
JSON
.
stringify
(
err
)
);
})
```
...
...
@@ -1217,11 +1239,11 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>)
```
js
inputMethodSetting
.
listInputMethod
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
error
(
'
listInputMethod failed because
:
'
+
JSON
.
stringify
(
err
));
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to listInputMethod
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
listInputMethod success
'
);
console
.
log
(
'
Succeeded in listing inputMethod.
'
);
});
```
...
...
@@ -1247,9 +1269,9 @@ listInputMethod(): Promise<Array<InputMethodProperty>>
```
js
inputMethodSetting
.
listInputMethod
().
then
((
data
)
=>
{
console
.
info
(
'
listInputMethod success
'
);
console
.
info
(
'
Succeeded in listing inputMethod.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
listInputMethod err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to listInputMethod
:
'
+
JSON
.
stringify
(
err
));
})
```
...
...
@@ -1275,11 +1297,11 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void
```
js
inputMethodSetting
.
displayOptionalInputMethod
((
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
displayOptionalInputMethod failed because
:
'
+
JSON
.
stringify
(
err
));
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to displayOptionalInputMethod
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
displayOptionalInputMethod success
'
);
console
.
info
(
'
Succeeded in displaying optionalInputMethod.
'
);
});
```
...
...
@@ -1305,8 +1327,8 @@ displayOptionalInputMethod(): Promise<void>
```
js
inputMethodSetting
.
displayOptionalInputMethod
().
then
(()
=>
{
console
.
info
(
'
displayOptionalInputMethod success
'
);
console
.
info
(
'
Succeeded in displaying optionalInputMethod.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
displayOptionalInputMethod err:
'
+
err
);
console
.
error
(
'
Failed to displayOptionalInputMethod:
'
+
JSON
.
stringify
(
err
)
);
})
```
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
浏览文件 @
f6c137f2
...
...
@@ -137,7 +137,7 @@ createKeyboardDelegate(): KeyboardDelegate
**示例:**
```
js
let
K
eyboardDelegate
=
inputMethodEngine
.
createKeyboardDelegate
();
let
k
eyboardDelegate
=
inputMethodEngine
.
createKeyboardDelegate
();
```
## InputMethodEngine
...
...
@@ -162,9 +162,9 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, textInputCli
**示例:**
```
js
inputMethodEngine
.
getInputMethodEngine
().
on
(
'
inputStart
'
,
(
kbController
,
text
Input
Client
)
=>
{
K
eyboardController
=
kbController
;
TextInputClient
=
textInpu
tClient
;
inputMethodEngine
.
getInputMethodEngine
().
on
(
'
inputStart
'
,
(
kbController
,
textClient
)
=>
{
let
k
eyboardController
=
kbController
;
let
textInputClient
=
tex
tClient
;
});
```
...
...
@@ -235,12 +235,8 @@ off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void
**示例:**
```
js
inputMethodEngine
.
getInputMethodEngine
().
off
(
'
keyboardShow
'
,
()
=>
{
console
.
log
(
'
inputMethodEngine delete keyboardShow notification.
'
);
});
inputMethodEngine
.
getInputMethodEngine
().
off
(
'
keyboardHide
'
,
()
=>
{
console
.
log
(
'
inputMethodEngine delete keyboardHide notification.
'
);
});
inputMethodEngine
.
getInputMethodEngine
().
off
(
'
keyboardShow
'
);
inputMethodEngine
.
getInputMethodEngine
().
off
(
'
keyboardHide
'
);
```
## InputMethodAbility
...
...
@@ -265,9 +261,9 @@ on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient:
**示例:**
```
js
inputMethodEngine
.
getInputMethodAbility
().
on
(
'
inputStart
'
,
(
kbController
,
inputC
lient
)
=>
{
K
eyboardController
=
kbController
;
InputClient
=
inputC
lient
;
inputMethodEngine
.
getInputMethodAbility
().
on
(
'
inputStart
'
,
(
kbController
,
c
lient
)
=>
{
let
k
eyboardController
=
kbController
;
let
inputClient
=
c
lient
;
});
```
...
...
@@ -289,9 +285,7 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, inputClien
**示例:**
```
js
inputMethodEngine
.
getInputMethodAbility
().
off
(
'
inputStart
'
,
(
kbController
,
inputClient
)
=>
{
console
.
log
(
'
delete inputStart notification.
'
);
});
inputMethodEngine
.
getInputMethodAbility
().
off
(
'
inputStart
'
);
```
### on('inputStop')<sup>9+</sup>
...
...
@@ -492,7 +486,7 @@ inputMethodEngine.getInputMethodAbility().off('setSubtype', () => {
on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void
订阅硬键盘事件。使用callback异步回调。
订阅硬键盘
(即物理键盘)
事件。使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -522,7 +516,7 @@ inputMethodEngine.getKeyboardDelegate().on('keyDown', (keyEvent) => {
off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void
取消订阅硬键盘事件。使用callback异步回调。
取消订阅硬键盘
(即物理键盘)
事件。使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
...
...
@@ -602,14 +596,14 @@ on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegi
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 文本选择变化事件。
<br/>
-
type为’selectionChange‘时,表示选择文本变化。 |
| callback | (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void | 是 | 回调函数,返回文本选择信息。
<br/>
-
oldBegin为变化之前被选中文本的起始下标。
<br/>
-
oldEnd为变化之前被选中文本的终止下标。
<br/>
-
newBegin为变化之后被选中文本的起始下标。
<br/>
-
newEnd为变化之后被选中文本的终止下标。 |
**示例:**
**示例:**
```
js
inputMethodEngine
.
getKeyboardDelegate
().
on
(
'
selectionChange
'
,
(
oldBegin
,
oldEnd
,
newBegin
,
newEnd
)
=>
{
...
...
@@ -652,14 +646,14 @@ on(type: 'textChange', callback: (text: string) => void): void
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 文本变化事件。
<br/>
-
type为’textChange‘时,表示订阅文本变化事件。 |
| callback | (text: string) => void | 是 | 回调函数,返回订阅的文本内容。 |
**示例:**
**示例:**
```
js
inputMethodEngine
.
getKeyboardDelegate
().
on
(
'
textChange
'
,
(
text
)
=>
{
...
...
@@ -719,12 +713,12 @@ hide(callback: AsyncCallback<void>): void
**示例:**
```
js
K
eyboardController
.
hide
((
err
)
=>
{
if
(
err
=
==
undefined
)
{
console
.
error
(
'
hide err
:
'
+
JSON
.
stringify
(
err
));
k
eyboardController
.
hide
((
err
)
=>
{
if
(
err
!
==
undefined
)
{
console
.
error
(
'
Failed to hide keyboard
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
hide success
.
'
);
console
.
log
(
'
Succeeded in hiding keyboard
.
'
);
});
```
...
...
@@ -753,10 +747,10 @@ hide(): Promise<void>
**示例:**
```
js
K
eyboardController
.
hide
().
then
(()
=>
{
console
.
info
(
'
hide success
.
'
);
k
eyboardController
.
hide
().
then
(()
=>
{
console
.
info
(
'
Succeeded in hiding keyboard
.
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
hide err
:
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
Failed to hide keyboard
:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -781,12 +775,12 @@ hideKeyboard(callback: AsyncCallback<void>): void
**示例:**
```
js
K
eyboardController
.
hideKeyboard
((
err
)
=>
{
if
(
err
=
==
undefined
)
{
console
.
error
(
'
hideKeyboard err
:
'
+
JSON
.
stringify
(
err
));
k
eyboardController
.
hideKeyboard
((
err
)
=>
{
if
(
err
!
==
undefined
)
{
console
.
error
(
'
Failed to hide Keyboard
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
hideKeyboard success
.
'
);
console
.
log
(
'
Succeeded in hiding keyboard
.
'
);
});
```
...
...
@@ -811,10 +805,10 @@ hideKeyboard(): Promise<void>
**示例:**
```
js
K
eyboardController
.
hideKeyboard
().
then
(()
=>
{
console
.
info
(
'
hideKeyboard success
.
'
);
k
eyboardController
.
hideKeyboard
().
then
(()
=>
{
console
.
info
(
'
Succeeded in hiding keyboard
.
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
hideKeyboard err
:
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
Failed to hide Keyboard
:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -850,13 +844,13 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void
```
js
let
action
=
1
;
try
{
I
nputClient
.
sendKeyFunction
(
action
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
sendKeyFunction err
:
'
+
JSON
.
stringify
(
err
));
i
nputClient
.
sendKeyFunction
(
action
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to sendKeyFunction
:
'
+
JSON
.
stringify
(
err
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succe
ss to sendKeyF
unction.
'
);
console
.
info
(
'
Succe
eded in sending key f
unction.
'
);
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.
'
);
}
...
...
@@ -899,17 +893,17 @@ sendKeyFunction(action: number): Promise<boolean>
```
js
let
action
=
1
;
try
{
I
nputClient
.
sendKeyFunction
(
action
).
then
((
result
)
=>
{
i
nputClient
.
sendKeyFunction
(
action
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succe
ss to sendKeyF
unction.
'
);
console
.
info
(
'
Succe
eded in sending key f
unction.
'
);
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
sendKeyFunction err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to sendKeyFunction
:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
console
.
error
(
'
sendKeyFunction err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to sendKeyFunction
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -942,15 +936,15 @@ getForward(length:number, callback: AsyncCallback<string>): void
```
js
let
length
=
1
;
try
{
I
nputClient
.
getForward
(
length
,
(
err
,
text
)
=>
{
if
(
err
)
{
console
.
error
(
'
getForward err
:
'
+
JSON
.
stringify
(
err
));
i
nputClient
.
getForward
(
length
,
(
err
,
text
)
=>
{
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to getForward
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
getForward resul
t:
'
+
text
);
console
.
log
(
'
Succeeded in getting forward, tex
t:
'
+
text
);
});
}
catch
(
err
)
{
console
.
error
(
'
getForward err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to getForward
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -988,13 +982,13 @@ getForward(length:number): Promise<string>
```
js
let
length
=
1
;
try
{
I
nputClient
.
getForward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getForward resul
:
'
+
text
);
i
nputClient
.
getForward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
Succeeded in getting forward, text
:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getForward err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to getForward
:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
console
.
error
(
'
getForward err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to getForward
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1027,15 +1021,15 @@ getBackward(length:number, callback: AsyncCallback<string>): void
```
js
let
length
=
1
;
try
{
I
nputClient
.
getBackward
(
length
,
(
err
,
text
)
=>
{
if
(
err
)
{
console
.
error
(
'
getBackward result
:
'
+
JSON
.
stringify
(
err
));
i
nputClient
.
getBackward
(
length
,
(
err
,
text
)
=>
{
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to getForward
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
getBackward result---
text:
'
+
text
);
console
.
log
(
'
Succeeded in getting backward,
text:
'
+
text
);
});
}
catch
(
err
)
{
console
.
error
(
'
getBackward result
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to getForward
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1073,13 +1067,13 @@ getBackward(length:number): Promise<string>
```
js
let
length
=
1
;
try
{
I
nputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getBackward resul
t:
'
+
text
);
i
nputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
Succeeded in getting backward, tex
t:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getBackward err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to getForward
:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
console
.
error
(
'
getBackward err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to getForward
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1112,19 +1106,19 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
```
js
let
length
=
1
;
try
{
I
nputClient
.
deleteForward
(
length
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
deleteForward result
:
'
+
JSON
.
stringify
(
err
));
i
nputClient
.
deleteForward
(
length
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to delete forward
:
'
+
JSON
.
stringify
(
err
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succe
ss to deleteF
orward.
'
);
console
.
info
(
'
Succe
eded in deleting f
orward.
'
);
}
else
{
console
.
error
(
'
Failed to delete
Forward.
'
);
console
.
error
(
'
Failed to delete
forward:
'
+
JSON
.
stringify
(
err
)
);
}
});
}
catch
(
err
)
{
console
.
error
(
'
deleteForward result
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to delete forward
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1162,17 +1156,17 @@ deleteForward(length:number): Promise<boolean>
```
js
let
length
=
1
;
try
{
I
nputClient
.
deleteForward
(
length
).
then
((
result
)
=>
{
i
nputClient
.
deleteForward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succe
ss to deleteF
orward.
'
);
console
.
info
(
'
Succe
eded in deleting f
orward.
'
);
}
else
{
console
.
error
(
'
Failed to deleteForward.
'
);
console
.
error
(
'
Failed to delete
Forward.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteForward err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to delete Forward
:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
console
.
error
(
'
deleteForward err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to delete Forward
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1205,15 +1199,15 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void
```
js
let
length
=
1
;
try
{
I
nputClient
.
deleteBackward
(
length
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
deleteBackward err
:
'
+
JSON
.
stringify
(
err
));
i
nputClient
.
deleteBackward
(
length
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to delete Backward
:
'
+
JSON
.
stringify
(
err
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succe
ss to deleteB
ackward.
'
);
console
.
info
(
'
Succe
eded in deleting b
ackward.
'
);
}
else
{
console
.
error
(
'
Failed to delete
Backward.
'
);
console
.
error
(
'
Failed to delete
Backward:
'
+
JSON
.
stringify
(
err
)
);
}
});
}
catch
(
err
)
{
...
...
@@ -1254,14 +1248,14 @@ deleteBackward(length:number): Promise<boolean>
```
js
let
length
=
1
;
I
nputClient
.
deleteBackward
(
length
).
then
((
result
)
=>
{
i
nputClient
.
deleteBackward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succe
ss to deleteB
ackward.
'
);
console
.
info
(
'
Succe
eded in deleting b
ackward.
'
);
}
else
{
console
.
error
(
'
Failed to deleteBackward.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteBackward err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to deleteBackward
:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -1292,13 +1286,13 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
**示例:**
```
js
I
nputClient
.
insertText
(
'
test
'
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
insertText err
:
'
+
JSON
.
stringify
(
err
));
i
nputClient
.
insertText
(
'
test
'
,
(
err
,
result
)
=>
{
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to insertText
:
'
+
JSON
.
stringify
(
err
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succe
ss to insertT
ext.
'
);
console
.
info
(
'
Succe
eded in inserting t
ext.
'
);
}
else
{
console
.
error
(
'
Failed to insertText.
'
);
}
...
...
@@ -1338,17 +1332,17 @@ insertText(text:string): Promise<boolean>
```
js
try
{
I
nputClient
.
insertText
(
'
test
'
).
then
((
result
)
=>
{
i
nputClient
.
insertText
(
'
test
'
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succe
ss to insertT
ext.
'
);
console
.
info
(
'
Succe
eded in inserting t
ext.
'
);
}
else
{
console
.
error
(
'
Failed to insertText.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
insertText err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to insertText
:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
console
.
error
(
'
insertText err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to insertText
:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1377,9 +1371,9 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
**示例:**
```
js
I
nputClient
.
getEditorAttribute
((
err
,
editorAttribute
)
=>
{
if
(
err
)
{
console
.
error
(
'
getEditorAttribute err
:
'
+
JSON
.
stringify
(
err
));
i
nputClient
.
getEditorAttribute
((
err
,
editorAttribute
)
=>
{
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to getEditorAttribute
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
...
...
@@ -1412,11 +1406,11 @@ getEditorAttribute(): Promise<EditorAttribute>
**示例:**
```
js
I
nputClient
.
getEditorAttribute
().
then
((
editorAttribute
)
=>
{
i
nputClient
.
getEditorAttribute
().
then
((
editorAttribute
)
=>
{
console
.
info
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
console
.
info
(
'
editorAttribute.enterKeyType:
'
+
JSON
.
stringify
(
editorAttribute
.
enterKeyType
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
getEditorAttribute err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to getEditorAttribute
:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -1447,15 +1441,15 @@ moveCursor(direction: number, callback: AsyncCallback<void>): void
```
js
try
{
InputClient
.
moveCursor
(
inputMethodEngine
.
CURSOR_xxx
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
moveCursor er
r:
'
+
JSON
.
stringify
(
err
));
inputClient
.
moveCursor
(
inputMethodEngine
.
CURSOR_UP
,
(
err
)
=>
{
if
(
err
!==
undefined
)
{
console
.
error
(
'
Failed to moveCurso
r:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
moveCursor success
'
);
console
.
info
(
'
Succeeded in moving cursor.
'
);
});
}
catch
(
err
)
{
console
.
error
(
'
moveCursor er
r:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to moveCurso
r:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1491,13 +1485,13 @@ moveCursor(direction: number): Promise<void>
```
js
try
{
I
nputClient
.
moveCursor
(
inputMethodEngine
.
CURSOR_UP
).
then
(()
=>
{
console
.
log
(
'
moveCursor success
'
);
i
nputClient
.
moveCursor
(
inputMethodEngine
.
CURSOR_UP
).
then
(()
=>
{
console
.
log
(
'
Succeeded in moving cursor.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
moveCursor success er
r:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to moveCurso
r:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
console
.
log
(
'
moveCursor er
r:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
Failed to moveCurso
r:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1554,12 +1548,12 @@ getForward(length:number, callback: AsyncCallback<string>): void
```
js
let
length
=
1
;
T
extInputClient
.
getForward
(
length
,
(
err
,
text
)
=>
{
if
(
err
=
==
undefined
)
{
console
.
error
(
'
getForward err
:
'
+
JSON
.
stringify
(
err
));
t
extInputClient
.
getForward
(
length
,
(
err
,
text
)
=>
{
if
(
err
!
==
undefined
)
{
console
.
error
(
'
Failed to getForward
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
getForward result---
text:
'
+
text
);
console
.
log
(
'
Succeeded in getting forward,
text:
'
+
text
);
});
```
...
...
@@ -1591,10 +1585,10 @@ getForward(length:number): Promise<string>
```
js
let
length
=
1
;
T
extInputClient
.
getForward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getForward result:
'
+
JSON
.
stringify
(
text
)
);
t
extInputClient
.
getForward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
Succeeded in getting forward, text:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getForward err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to getForward
:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -1621,12 +1615,12 @@ getBackward(length:number, callback: AsyncCallback<string>): void
```
js
let
length
=
1
;
T
extInputClient
.
getBackward
(
length
,
(
err
,
text
)
=>
{
if
(
err
=
==
undefined
)
{
console
.
error
(
'
getBackward err
:
'
+
JSON
.
stringify
(
err
));
t
extInputClient
.
getBackward
(
length
,
(
err
,
text
)
=>
{
if
(
err
!
==
undefined
)
{
console
.
error
(
'
Failed to getBackward
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
getBackward result---
text:
'
+
text
);
console
.
log
(
'
Succeeded in getting borward,
text:
'
+
text
);
});
```
...
...
@@ -1658,10 +1652,10 @@ getBackward(length:number): Promise<string>
```
js
let
length
=
1
;
T
extInputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getBackward result
:
'
+
JSON
.
stringify
(
text
));
t
extInputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
Succeeded in getting backward
:
'
+
JSON
.
stringify
(
text
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
getBackward err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to getBackward
:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -1688,13 +1682,13 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void
```
js
let
length
=
1
;
T
extInputClient
.
deleteForward
(
length
,
(
err
,
result
)
=>
{
if
(
err
=
==
undefined
)
{
console
.
error
(
'
deleteForward err
:
'
+
JSON
.
stringify
(
err
));
t
extInputClient
.
deleteForward
(
length
,
(
err
,
result
)
=>
{
if
(
err
!
==
undefined
)
{
console
.
error
(
'
Failed to deleteForward
:
'
+
JSON
.
stringify
(
err
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succe
ss to deleteF
orward.
'
);
console
.
info
(
'
Succe
eded in deleting f
orward.
'
);
}
else
{
console
.
error
(
'
Failed to deleteForward.
'
);
}
...
...
@@ -1729,14 +1723,14 @@ deleteForward(length:number): Promise<boolean>
```
js
let
length
=
1
;
T
extInputClient
.
deleteForward
(
length
).
then
((
result
)
=>
{
t
extInputClient
.
deleteForward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succeed in deleting forward.
'
);
console
.
info
(
'
Succeed
ed
in deleting forward.
'
);
}
else
{
console
.
error
(
'
Failed to delete forward.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to delete forward
err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to delete forward:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -1763,13 +1757,13 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void
```
js
let
length
=
1
;
T
extInputClient
.
deleteBackward
(
length
,
(
err
,
result
)
=>
{
if
(
err
=
==
undefined
)
{
console
.
error
(
'
deleteBackward err
:
'
+
JSON
.
stringify
(
err
));
t
extInputClient
.
deleteBackward
(
length
,
(
err
,
result
)
=>
{
if
(
err
!
==
undefined
)
{
console
.
error
(
'
Failed to delete backward
:
'
+
JSON
.
stringify
(
err
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succe
ss to deleteB
ackward.
'
);
console
.
info
(
'
Succe
eded in deleting b
ackward.
'
);
}
else
{
console
.
error
(
'
Failed to deleteBackward.
'
);
}
...
...
@@ -1804,14 +1798,14 @@ deleteBackward(length:number): Promise<boolean>
```
js
let
length
=
1
;
T
extInputClient
.
deleteBackward
(
length
).
then
((
result
)
=>
{
t
extInputClient
.
deleteBackward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succe
ss to deleteB
ackward.
'
);
console
.
info
(
'
Succe
eded in deleting b
ackward.
'
);
}
else
{
console
.
error
(
'
Failed to deleteBackward.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteBackward err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to deleteBackward
:
'
+
JSON
.
stringify
(
err
));
});
```
### sendKeyFunction<sup>(deprecated)</sup>
...
...
@@ -1837,13 +1831,13 @@ sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void
```
js
let
action
=
1
;
T
extInputClient
.
sendKeyFunction
(
action
,
(
err
,
result
)
=>
{
if
(
err
=
==
undefined
)
{
console
.
error
(
'
sendKeyFunction err
:
'
+
JSON
.
stringify
(
err
));
t
extInputClient
.
sendKeyFunction
(
action
,
(
err
,
result
)
=>
{
if
(
err
!
==
undefined
)
{
console
.
error
(
'
Failed to sendKeyFunction
:
'
+
JSON
.
stringify
(
err
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succe
ss to sendKeyF
unction.
'
);
console
.
info
(
'
Succe
eded in sending key f
unction.
'
);
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.
'
);
}
...
...
@@ -1878,14 +1872,14 @@ sendKeyFunction(action: number): Promise<boolean>
```
js
let
action
=
1
;
T
extInputClient
.
sendKeyFunction
(
action
).
then
((
result
)
=>
{
t
extInputClient
.
sendKeyFunction
(
action
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succe
ss to sendKeyF
unction.
'
);
console
.
info
(
'
Succe
eded in sending key f
unction.
'
);
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
sendKeyFunction err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to sendKeyFunction
:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -1911,13 +1905,13 @@ insertText(text:string, callback: AsyncCallback<boolean>): void
**示例:**
```
js
T
extInputClient
.
insertText
(
'
test
'
,
(
err
,
result
)
=>
{
if
(
err
=
==
undefined
)
{
console
.
error
(
'
insertText err
:
'
+
JSON
.
stringify
(
err
));
t
extInputClient
.
insertText
(
'
test
'
,
(
err
,
result
)
=>
{
if
(
err
!
==
undefined
)
{
console
.
error
(
'
Failed to insertText
:
'
+
JSON
.
stringify
(
err
));
return
;
}
if
(
result
)
{
console
.
info
(
'
Succe
ss to insertT
ext.
'
);
console
.
info
(
'
Succe
eded in inserting t
ext.
'
);
}
else
{
console
.
error
(
'
Failed to insertText.
'
);
}
...
...
@@ -1951,14 +1945,14 @@ insertText(text:string): Promise<boolean>
**示例:**
```
js
T
extInputClient
.
insertText
(
'
test
'
).
then
((
result
)
=>
{
t
extInputClient
.
insertText
(
'
test
'
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succe
ss to insertT
ext.
'
);
console
.
info
(
'
Succe
eded in inserting t
ext.
'
);
}
else
{
console
.
error
(
'
Failed to insertText.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
insertText err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to insertText
:
'
+
JSON
.
stringify
(
err
));
});
```
...
...
@@ -1983,9 +1977,9 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
**示例:**
```
js
T
extInputClient
.
getEditorAttribute
((
err
,
editorAttribute
)
=>
{
if
(
err
=
==
undefined
)
{
console
.
error
(
'
getEditorAttribute err
:
'
+
JSON
.
stringify
(
err
));
t
extInputClient
.
getEditorAttribute
((
err
,
editorAttribute
)
=>
{
if
(
err
!
==
undefined
)
{
console
.
error
(
'
Failed to getEditorAttribute
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
...
...
@@ -2014,10 +2008,10 @@ getEditorAttribute(): Promise<EditorAttribute>
**示例:**
```
js
T
extInputClient
.
getEditorAttribute
().
then
((
editorAttribute
)
=>
{
t
extInputClient
.
getEditorAttribute
().
then
((
editorAttribute
)
=>
{
console
.
info
(
'
editorAttribute.inputPattern:
'
+
JSON
.
stringify
(
editorAttribute
.
inputPattern
));
console
.
info
(
'
editorAttribute.enterKeyType:
'
+
JSON
.
stringify
(
editorAttribute
.
enterKeyType
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
getEditorAttribute err
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to getEditorAttribute
:
'
+
JSON
.
stringify
(
err
));
});
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录