Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
0f3fe2cb
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看板
未验证
提交
0f3fe2cb
编写于
11月 11, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
!11356 部分示例代码修改及多余接口删除
Merge pull request !11356 from Hollokin/master
上级
74a2c60a
c564b9a7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
166 addition
and
272 deletion
+166
-272
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
+32
-8
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
...plication-dev/reference/apis/js-apis-inputmethodengine.md
+134
-264
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
浏览文件 @
0f3fe2cb
...
...
@@ -126,7 +126,7 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolea
```
js
try
{
inputMethod
.
switchInputMethod
({
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
},
(
err
,
result
)
=>
{
inputMethod
.
switchInputMethod
({
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
,
extra
:
{}
},
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
switchInputMethod err:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -175,7 +175,7 @@ switchInputMethod(target: InputMethodProperty): Promise<boolean>
```
js
try
{
inputMethod
.
switchInputMethod
({
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
}).
then
((
result
)
=>
{
inputMethod
.
switchInputMethod
({
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
,
extra
:
{}
}).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to switchInputMethod.
'
);
}
else
{
...
...
@@ -240,7 +240,14 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb
```
js
let
inputMethodSubtype
=
{
id
:
"
com.example.kikainput
"
,
label
:
"
ServiceExtAbility
"
label
:
"
ServiceExtAbility
"
,
name
:
""
,
mode
:
"
upper
"
,
locale
:
""
,
language
:
""
,
icon
:
""
,
iconId
:
0
,
extra
:
{}
}
try
{
inputMethod
.
switchCurrentInputMethodSubtype
(
inputMethodSubtype
,
(
err
,
result
)
=>
{
...
...
@@ -295,7 +302,14 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise<boolean&
```
js
let
inputMethodSubtype
=
{
id
:
"
com.example.kikainput
"
,
label
:
"
ServiceExtAbility
"
label
:
"
ServiceExtAbility
"
,
name
:
""
,
mode
:
"
upper
"
,
locale
:
""
,
language
:
""
,
icon
:
""
,
iconId
:
0
,
extra
:
{}
}
try
{
inputMethod
.
switchCurrentInputMethodSubtype
(
inputMethodSubtype
).
then
((
result
)
=>
{
...
...
@@ -363,12 +377,20 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
```
js
let
inputMethodProperty
=
{
packageName
:
"
com.example.kikakeyboard
"
,
methodId
:
"
ServiceExtAbility
"
packageName
:
"
com.example.kikakeyboard
"
,
methodId
:
"
ServiceExtAbility
"
,
extra
:
{}
}
let
inputMethodSubProperty
=
{
id
:
"
com.example.kikainput
"
,
label
:
"
ServiceExtAbility
"
label
:
"
ServiceExtAbility
"
,
name
:
""
,
mode
:
"
upper
"
,
locale
:
""
,
language
:
""
,
icon
:
""
,
iconId
:
0
,
extra
:
{}
}
try
{
inputMethod
.
switchCurrentInputMethodAndSubtype
(
inputMethodProperty
,
inputMethodSubProperty
,
(
err
,
result
)
=>
{
...
...
@@ -873,7 +895,8 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async
```
js
let
inputMethodProperty
=
{
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
methodId
:
'
com.example.kikakeyboard
'
,
extra
:{}
}
try
{
InputMethodSetting
.
listInputMethodSubtype
(
inputMethodProperty
,
(
err
,
data
)
=>
{
...
...
@@ -923,6 +946,7 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<Arr
let
inputMethodProperty
=
{
packageName
:
'
com.example.kikakeyboard
'
,
methodId
:
'
com.example.kikakeyboard
'
,
extra
:{}
}
try
{
InputMethodSetting
.
listInputMethodSubtype
(
inputMethodProperty
).
then
((
data
)
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
浏览文件 @
0f3fe2cb
# 输入法服务
本模块的作用是拉通
普通应用和输入法应用,功能包括:普通应用通过输入法应用进行文本输入、普通应用与输入法服务绑定、普通应用对输入法应用进行显示请求和隐藏请求、普通应用对输入法应用当前状态进行监听等
等。
本模块的作用是拉通
输入法应用和其他三方应用(联系人、微信等),功能包括:将三方应用与输入法应用的服务进行绑定、三方应用通过输入法应用进行文本输入、三方应用对输入法应用进行显示键盘请求和隐藏键盘请求、三方应用对输入法应用当前状态进行监听
等。
> **说明:**
>
...
...
@@ -69,7 +69,7 @@ getInputMethodAbility(): InputMethodAbility
**示例:**
```
js
let
InputMethodAbility
=
inputMethod
Ability
.
getInputMethodAbility
();
let
InputMethodAbility
=
inputMethod
Engine
.
getInputMethodAbility
();
```
## inputMethodEngine.getKeyboardDelegate<sup>9+</sup>
...
...
@@ -89,7 +89,7 @@ getKeyboardDelegate(): KeyboardDelegate
**示例:**
```
js
let
KeyboardDelegate
=
inputMethod
Ability
.
getKeyboardDelegate
();
let
KeyboardDelegate
=
inputMethod
Engine
.
getKeyboardDelegate
();
```
## inputMethodEngine.getInputMethodEngine<sup>(deprecated)</sup>
...
...
@@ -183,8 +183,6 @@ off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputC
| type | string | 是 | 设置监听类型。
<br/>
-type为‘inputStart’时表示订阅输入法绑定。 |
| callback |
[
KeyboardController
](
#keyboardcontroller
)
,
[
TextInputClient
](
#textinputclient
)
| 否 | 回调函数,返回取消订阅的KeyboardController和TextInputClient实例。 |
**示例:**
```
js
...
...
@@ -193,98 +191,6 @@ inputMethodEngine.getInputMethodEngine().off('inputStart', (kbController, textIn
});
```
### on('inputStop')<sup>9+</sup>
on(type: 'inputStop', callback: () => void): void
订阅停止输入法应用事件。使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘inputStop’时表示订阅停止输入法应用事件。 |
| callback | void | 是 | 回调函数。 |
**示例:**
```
js
inputMethodEngine
.
getInputMethodEngine
().
on
(
'
inputStop
'
,
()
=>
{
console
.
log
(
'
inputMethodEngine inputStop
'
);
});
```
### off('inputStop')<sup>9+</sup>
off(type: 'inputStop', callback: () => void): void
取消订阅停止输入法应用事件。使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘inputStop’时表示订阅停止输入法应用事件。 |
| callback | void | 是 | 回调函数。 |
**示例:**
```
js
inputMethodEngine
.
getInputMethodEngine
().
off
(
'
inputStop
'
,
()
=>
{
console
.
log
(
'
inputMethodEngine delete inputStop notification.
'
);
});
```
### on('setCallingWindow')<sup>9+</sup>
on(type: 'setCallingWindow', callback: (wid:number) => void): void
订阅设置调用窗口事件。使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘setCallingWindow’时表示订阅设置调用窗口事件。 |
| callback | number | 是 | 回调函数,返回调用方window id。 |
**示例:**
```
js
inputMethodEngine
.
getInputMethodEngine
().
on
(
'
setCallingWindow
'
,
(
wid
)
=>
{
console
.
log
(
'
inputMethodEngine setCallingWindow
'
);
});
```
### off('setCallingWindow')<sup>9+</sup>
off(type: 'setCallingWindow', callback: (wid:number) => void): void
取消订阅设置调用窗口事件。使用callback异步回调。
**系统能力:**
SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。
<br/>
-type为‘setCallingWindow’时表示订阅设置调用窗口事件。 |
| callback | number | 是 | 回调函数,返回调用方window id。 |
**示例:**
```
js
inputMethodEngine
.
getInputMethodEngine
().
off
(
'
setCallingWindow
'
,
()
=>
{
console
.
log
(
'
inputMethodEngine delete setCallingWindow notification.
'
);
});
```
### on('keyboardShow'|'keyboardHide')
on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void
...
...
@@ -849,13 +755,11 @@ hide(): Promise<void>
**示例:**
```
js
async
function
InputMethodEngine
()
{
await
KeyboardController
.
hide
().
then
(()
=>
{
console
.
info
(
'
hide success.
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
hide err:
'
+
JSON
.
stringify
(
err
));
});
}
KeyboardController
.
hide
().
then
(()
=>
{
console
.
info
(
'
hide success.
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
hide err:
'
+
JSON
.
stringify
(
err
));
});
```
### hideKeyboard<sup>(deprecated)</sup>
...
...
@@ -909,13 +813,11 @@ hideKeyboard(): Promise<void>
**示例:**
```
js
async
function
InputMethodEngine
()
{
await
KeyboardController
.
hideKeyboard
().
then
(()
=>
{
console
.
info
(
'
hideKeyboard success.
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
hideKeyboard err:
'
+
JSON
.
stringify
(
err
));
});
}
KeyboardController
.
hideKeyboard
().
then
(()
=>
{
console
.
info
(
'
hideKeyboard success.
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
hideKeyboard err:
'
+
JSON
.
stringify
(
err
));
});
```
## InputClient<sup>9+</sup>
...
...
@@ -951,7 +853,7 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void
try
{
InputClient
.
sendKeyFunction
(
keyFunction
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
'
sendKeyFunction err:
'
+
JSON
.
stringify
(
err
)
JSON
.
stringify
(
err
)
);
console
.
error
(
'
sendKeyFunction err:
'
+
JSON
.
stringify
(
err
));
return
;
}
if
(
result
)
{
...
...
@@ -1084,17 +986,15 @@ getForward(length:number): Promise<string>
**示例:**
```
js
async
function
InputMethodAbility
()
{
let
length
=
1
;
try
{
await
InputClient
.
getForward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getForward resul:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getForward err:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
let
length
=
1
;
try
{
InputClient
.
getForward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getForward resul:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getForward err:
'
+
JSON
.
stringify
(
err
));
}
});
}
catch
(
err
)
{
console
.
error
(
'
getForward err:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1171,17 +1071,15 @@ getBackward(length:number): Promise<string>
**示例:**
```
js
async
function
InputMethodAbility
()
{
let
length
=
1
;
try
{
await
InputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getBackward result:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getBackward err:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
let
length
=
1
;
try
{
InputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getBackward result:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getBackward err:
'
+
JSON
.
stringify
(
err
));
}
});
}
catch
(
err
)
{
console
.
error
(
'
getBackward err:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1262,21 +1160,19 @@ deleteForward(length:number): Promise<boolean>
**示例:**
```
js
async
function
InputMethodAbility
()
{
let
length
=
1
;
try
{
await
InputClient
.
deleteForward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to deleteForward.
'
);
}
else
{
console
.
error
(
'
Failed to deleteForward.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteForward err:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
let
length
=
1
;
try
{
InputClient
.
deleteForward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to deleteForward.
'
);
}
else
{
console
.
error
(
'
Failed to deleteForward.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteForward err:
'
+
JSON
.
stringify
(
err
));
}
});
}
catch
(
err
)
{
console
.
error
(
'
deleteForward err:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1357,18 +1253,16 @@ deleteBackward(length:number): Promise<boolean>
**示例:**
```
js
async
function
InputMethodAbility
()
{
let
length
=
1
;
await
InputClient
.
deleteBackward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to deleteBackward.
'
);
}
else
{
console
.
error
(
'
Failed to deleteBackward.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteBackward err:
'
+
JSON
.
stringify
(
err
));
});
}
let
length
=
1
;
InputClient
.
deleteBackward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to deleteBackward.
'
);
}
else
{
console
.
error
(
'
Failed to deleteBackward.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteBackward err:
'
+
JSON
.
stringify
(
err
));
});
```
### insertText<sup>9+</sup>
...
...
@@ -1443,20 +1337,18 @@ insertText(text:string): Promise<boolean>
**示例:**
```
js
async
function
InputMethodAbility
()
{
try
{
await
InputClient
.
insertText
(
'
test
'
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to insertText.
'
);
}
else
{
console
.
error
(
'
Failed to insertText.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
insertText err:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
e
)
{
try
{
InputClient
.
insertText
(
'
test
'
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to insertText.
'
);
}
else
{
console
.
error
(
'
Failed to insertText.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
insertText err:
'
+
JSON
.
stringify
(
err
));
}
});
}
catch
(
err
)
{
console
.
error
(
'
insertText err:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1520,14 +1412,12 @@ getEditorAttribute(): Promise<EditorAttribute>
**示例:**
```
js
async
function
InputMethodEngine
()
{
await
InputClient
.
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
));
});
}
InputClient
.
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
));
});
```
### moveCursor<sup>9+</sup>
...
...
@@ -1557,7 +1447,7 @@ moveCursor(direction: number, callback: AsyncCallback<void>): void
```
js
try
{
InputClient
.
moveCursor
(
inputMethod
Ability
.
CURSOR_xxx
,
(
err
)
=>
{
InputClient
.
moveCursor
(
inputMethod
Engine
.
CURSOR_xxx
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
'
moveCursor err:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -1600,20 +1490,14 @@ moveCursor(direction: number): Promise<void>
**示例:**
```
js
async
function
InputMethodAbility
()
{
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
(
err
)
{
console
.
log
(
'
moveCursor err:
'
+
JSON
.
stringify
(
err
));
}
try
{
InputClient
.
moveCursor
(
inputMethodEngine
.
CURSOR_UP
).
then
(()
=>
{
console
.
log
(
'
moveCursor success
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
moveCursor success err:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
err
)
{
console
.
log
(
'
moveCursor err:
'
+
JSON
.
stringify
(
err
));
}
```
...
...
@@ -1706,14 +1590,12 @@ getForward(length:number): Promise<string>
**示例:**
```
js
async
function
InputMethodEngine
()
{
let
length
=
1
;
await
TextInputClient
.
getForward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getForward result---res:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getForward err:
'
+
JSON
.
stringify
(
err
));
});
}
let
length
=
1
;
TextInputClient
.
getForward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getForward result:
'
+
JSON
.
stringify
(
text
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
getForward err:
'
+
JSON
.
stringify
(
err
));
});
```
### getBackward<sup>(deprecated)</sup>
...
...
@@ -1775,14 +1657,12 @@ getBackward(length:number): Promise<string>
**示例:**
```
js
async
function
InputMethodEngine
()
{
let
length
=
1
;
await
TextInputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getBackward result---res:
'
+
text
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
getBackward err:
'
+
JSON
.
stringify
(
err
));
});
}
let
length
=
1
;
TextInputClient
.
getBackward
(
length
).
then
((
text
)
=>
{
console
.
info
(
'
getBackward result:
'
+
JSON
.
stringify
(
text
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
getBackward err:
'
+
JSON
.
stringify
(
err
));
});
```
### deleteForward<sup>(deprecated)</sup>
...
...
@@ -1848,18 +1728,16 @@ deleteForward(length:number): Promise<boolean>
**示例:**
```
js
async
function
InputMethodEngine
()
{
let
length
=
1
;
await
TextInputClient
.
deleteForward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to deleteForward.
'
);
}
else
{
console
.
error
(
'
Failed to deleteForward.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteForward err:
'
+
JSON
.
stringify
(
err
));
});
}
let
length
=
1
;
TextInputClient
.
deleteForward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Succeed in deleting forward.
'
);
}
else
{
console
.
error
(
'
Failed to delete forward.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to delete forward err:
'
+
JSON
.
stringify
(
err
));
});
```
### deleteBackward<sup>(deprecated)</sup>
...
...
@@ -1925,18 +1803,16 @@ deleteBackward(length:number): Promise<boolean>
**示例:**
```
js
async
function
InputMethodEngine
()
{
let
length
=
1
;
await
TextInputClient
.
deleteBackward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to deleteBackward.
'
);
}
else
{
console
.
error
(
'
Failed to deleteBackward.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteBackward err:
'
+
JSON
.
stringify
(
err
));
});
}
let
length
=
1
;
TextInputClient
.
deleteBackward
(
length
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to deleteBackward.
'
);
}
else
{
console
.
error
(
'
Failed to deleteBackward.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
deleteBackward err:
'
+
JSON
.
stringify
(
err
));
});
```
### sendKeyFunction<sup>(deprecated)</sup>
...
...
@@ -2000,17 +1876,15 @@ sendKeyFunction(action:number): Promise<boolean>
**示例:**
```
js
async
function
InputMethodEngine
()
{
await
client
.
sendKeyFunction
(
keyFunction
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to sendKeyFunction.
'
);
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
sendKeyFunction err:
'
+
JSON
.
stringify
(
err
));
});
}
TextInputClient
.
sendKeyFunction
(
keyFunction
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to sendKeyFunction.
'
);
}
else
{
console
.
error
(
'
Failed to sendKeyFunction.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
sendKeyFunction err:
'
+
JSON
.
stringify
(
err
));
});
```
### insertText<sup>(deprecated)</sup>
...
...
@@ -2075,17 +1949,15 @@ insertText(text:string): Promise<boolean>
**示例:**
```
js
async
function
InputMethodEngine
()
{
await
TextInputClient
.
insertText
(
'
test
'
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to insertText.
'
);
}
else
{
console
.
error
(
'
Failed to insertText.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
insertText err:
'
+
JSON
.
stringify
(
err
));
});
}
TextInputClient
.
insertText
(
'
test
'
).
then
((
result
)
=>
{
if
(
result
)
{
console
.
info
(
'
Success to insertText.
'
);
}
else
{
console
.
error
(
'
Failed to insertText.
'
);
}
}).
catch
((
err
)
=>
{
console
.
error
(
'
insertText err:
'
+
JSON
.
stringify
(
err
));
});
```
### getEditorAttribute<sup>(deprecated)</sup>
...
...
@@ -2140,12 +2012,10 @@ getEditorAttribute(): Promise<EditorAttribute>
**示例:**
```
js
async
function
InputMethodEngine
()
{
await
TextInputClient
.
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
));
});
}
TextInputClient
.
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
));
});
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录