Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
cd748d72
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看板
提交
cd748d72
编写于
8月 26, 2022
作者:
Z
zhaolinglan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify example code
Signed-off-by:
N
zhaolinglan
<
zhaolinglan@huawei.com
>
上级
2a9be9dd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
54 addition
and
55 deletion
+54
-55
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
+54
-55
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
浏览文件 @
cd748d72
...
@@ -94,12 +94,16 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolea
...
@@ -94,12 +94,16 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolea
**示例:**
**示例:**
```
js
```
js
inputMethod
.
switchInputMethod
({
packageName
:
"
com.example.kikakeyboard
"
,
methodId
:
"
com.example.kikakeyboard
"
}
,(
err
,
data
)
=>
{
inputMethod
.
switchInputMethod
({
packageName
:
"
com.example.kikakeyboard
"
,
methodId
:
"
com.example.kikakeyboard
"
}
,(
err
,
result
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
"
switchInputMethod err:
"
+
JSON
.
stringify
(
err
));
console
.
error
(
"
switchInputMethod err:
"
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
log
(
"
switchInputMethod success result:
"
+
data
);
if
(
result
)
{
console
.
info
(
"
Success to switchInputMethod.(callback)
"
);
}
else
{
console
.
error
(
"
Failed to switchInputMethod.(callback)
"
);
}
});
});
```
```
## inputMethod.switchInputMethod<sup>9+</sup>
## inputMethod.switchInputMethod<sup>9+</sup>
...
@@ -124,18 +128,15 @@ switchInputMethod(target: InputMethodProperty): Promise<boolean>
...
@@ -124,18 +128,15 @@ switchInputMethod(target: InputMethodProperty): Promise<boolean>
```
js
```
js
async
function
InputMethod
()
{
inputMethod
.
switchInputMethod
({
packageName
:
"
com.example.kikakeyboard
"
,
methodId
:
"
com.example.kikakeyboard
"
}).
then
((
result
)
=>
{
await
inputMethod
.
switchInputMethod
({
packageName
:
"
com.example.kikakeyboard
"
,
if
(
result
)
{
methodId
:
"
com.example.kikakeyboard
"
}).
then
((
result
)
=>
{
console
.
info
(
"
Success to switchInputMethod.(promise)
"
);
if
(
result
)
{
}
else
{
console
.
info
(
"
Success to switchInputMethod.(promise)
"
);
console
.
error
(
"
Failed to switchInputMethod.(promise)
"
);
}
else
{
}
console
.
info
(
"
Failed to switchInputMethod.(promise)
"
);
}).
catch
((
err
)
=>
{
}
console
.
error
(
"
switchInputMethod promise err:
"
+
err
);
}).
catch
((
err
)
=>
{
})
console
.
info
(
"
switchInputMethod promise err:
"
+
err
);
});
}
```
```
## InputMethodController
## InputMethodController
...
@@ -158,12 +159,16 @@ stopInput(callback: AsyncCallback<boolean>): void
...
@@ -158,12 +159,16 @@ stopInput(callback: AsyncCallback<boolean>): void
**示例:**
**示例:**
```
js
```
js
InputMethodController
.
stopInput
((
error
,
data
)
=>
{
InputMethodController
.
stopInput
((
error
,
result
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
error
(
"
failed to stopInput because:
"
+
JSON
.
stringify
(
error
));
console
.
error
(
"
failed to stopInput because:
"
+
JSON
.
stringify
(
error
));
return
;
return
;
}
}
console
.
info
(
"
success stopInput:
"
+
JSON
.
stringify
(
data
));
if
(
result
)
{
console
.
info
(
"
Success to stopInput.(callback)
"
);
}
else
{
console
.
error
(
"
Failed to stopInput.(callback)
"
);
}
});
});
```
```
...
@@ -185,17 +190,15 @@ stopInput(): Promise<boolean>
...
@@ -185,17 +190,15 @@ stopInput(): Promise<boolean>
```
js
```
js
async
function
InputMethod
()
{
InputMethodController
.
stopInput
().
then
((
result
)
=>
{
await
InputMethodController
.
stopInput
().
then
((
result
)
=>
{
if
(
result
)
{
if
(
result
)
{
console
.
info
(
"
Success to stopInput.(promise)
"
);
console
.
info
(
"
Success to stopInput.(promise)
"
);
}
else
{
}
else
{
console
.
error
(
"
Failed to stopInput.(promise)
"
);
console
.
info
(
"
Failed to stopInput.(promise)
"
);
}
}
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
"
stopInput promise err:
"
+
err
);
console
.
error
(
"
stopInput promise err:
"
+
err
);
})
});
}
```
```
### showSoftKeyboard<sup>9+</sup> ###
### showSoftKeyboard<sup>9+</sup> ###
...
@@ -217,9 +220,9 @@ showSoftKeyboard(callback: AsyncCallback<void>): void
...
@@ -217,9 +220,9 @@ showSoftKeyboard(callback: AsyncCallback<void>): void
```
js
```
js
InputMethodController
.
showSoftKeyboard
((
err
)
=>
{
InputMethodController
.
showSoftKeyboard
((
err
)
=>
{
if
(
err
==
undefined
)
{
if
(
err
==
undefined
)
{
console
.
error
(
'
showSoftKeyboard success
'
);
console
.
info
(
'
showSoftKeyboard success
'
);
}
else
{
}
else
{
console
.
info
(
'
showSoftKeyboard failed
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
showSoftKeyboard failed because
:
'
+
JSON
.
stringify
(
err
));
}
}
})
})
```
```
...
@@ -245,7 +248,7 @@ showSoftKeyboard(): Promise<void>
...
@@ -245,7 +248,7 @@ showSoftKeyboard(): Promise<void>
InputMethodController
.
showSoftKeyboard
().
then
(
async
(
err
)
=>
{
InputMethodController
.
showSoftKeyboard
().
then
(
async
(
err
)
=>
{
console
.
log
(
'
showSoftKeyboard success
'
);
console
.
log
(
'
showSoftKeyboard success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
log
(
'
showSoftKeyboard fail
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
showSoftKeyboard promise err:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -268,9 +271,9 @@ hideSoftKeyboard(callback: AsyncCallback<void>): void
...
@@ -268,9 +271,9 @@ hideSoftKeyboard(callback: AsyncCallback<void>): void
```
js
```
js
InputMethodController
.
hideSoftKeyboard
((
err
)
=>
{
InputMethodController
.
hideSoftKeyboard
((
err
)
=>
{
if
(
err
==
undefined
)
{
if
(
err
==
undefined
)
{
console
.
error
(
'
hideSoftKeyboard success
'
);
console
.
info
(
'
hideSoftKeyboard success
'
);
}
else
{
}
else
{
console
.
info
(
'
hideSoftKeyboard failed
:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
hideSoftKeyboard failed because
:
'
+
JSON
.
stringify
(
err
));
}
}
})
})
```
```
...
@@ -296,7 +299,7 @@ hideSoftKeyboard(): Promise<void>
...
@@ -296,7 +299,7 @@ hideSoftKeyboard(): Promise<void>
InputMethodController
.
hideSoftKeyboard
().
then
(
async
(
err
)
=>
{
InputMethodController
.
hideSoftKeyboard
().
then
(
async
(
err
)
=>
{
console
.
log
(
'
hideSoftKeyboard success
'
);
console
.
log
(
'
hideSoftKeyboard success
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
log
(
'
hideSoftKeyboard fail
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
hideSoftKeyboard promise err:
'
+
JSON
.
stringify
(
err
));
});
});
```
```
...
@@ -322,11 +325,11 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>)
...
@@ -322,11 +325,11 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>)
```
js
```
js
imeList
:
Array
<
inputMethod
.
InputMethodProperty
>
=
null
imeList
:
Array
<
inputMethod
.
InputMethodProperty
>
=
null
InputMethodSetting
.
listInputMethod
((
err
,
data
)
=>
{
InputMethodSetting
.
listInputMethod
((
err
,
data
)
=>
{
if
(
err
==
undefined
)
{
if
(
err
)
{
console
.
error
(
"
fail to listInputMetho
d because:
"
+
JSON
.
stringify
(
err
));
console
.
error
(
"
listInputMethod faile
d because:
"
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
log
(
"
success listInputMethod
"
);
console
.
log
(
"
listInputMethod success
"
);
this
.
imeList
=
data
;
this
.
imeList
=
data
;
});
});
```
```
...
@@ -348,14 +351,12 @@ listInputMethod(): Promise<Array<InputMethodProperty>>
...
@@ -348,14 +351,12 @@ listInputMethod(): Promise<Array<InputMethodProperty>>
```
js
```
js
imeList
:
Array
<
inputMethod
.
InputMethodProperty
>
=
null
imeList
:
Array
<
inputMethod
.
InputMethodProperty
>
=
null
async
function
InputMethod
()
{
InputMethodSetting
.
listInputMethod
().
then
((
data
)
=>
{
await
InputMethodSetting
.
listInputMethod
().
then
((
data
)
=>
{
console
.
info
(
"
listInputMethod success
"
);
console
.
info
(
"
listInputMethod success
"
);
this
.
imeList
=
data
;
this
.
imeList
=
data
;
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
"
listInputMethod promise err:
"
+
err
);
console
.
info
(
"
listInputMethod promise err:
"
+
err
);
})
});
}
```
```
### displayOptionalInputMethod
### displayOptionalInputMethod
...
@@ -376,11 +377,11 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void
...
@@ -376,11 +377,11 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void
```
js
```
js
InputMethodSetting
.
displayOptionalInputMethod
((
err
)
=>
{
InputMethodSetting
.
displayOptionalInputMethod
((
err
)
=>
{
if
(
err
==
undefined
)
{
if
(
err
)
{
console
.
error
(
"
failed to displayOptionalInputMetho
d because:
"
+
JSON
.
stringify
(
err
));
console
.
error
(
"
displayOptionalInputMethod faile
d because:
"
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
"
success displayOptionalInputMethod
"
);
console
.
info
(
"
displayOptionalInputMethod success
"
);
});
});
```
```
...
@@ -401,11 +402,9 @@ InputMethodSetting.displayOptionalInputMethod((err) => {
...
@@ -401,11 +402,9 @@ InputMethodSetting.displayOptionalInputMethod((err) => {
**示例:**
**示例:**
```
js
```
js
async
function
InputMethod
()
{
InputMethodSetting
.
displayOptionalInputMethod
().
then
(()
=>
{
await
InputMethodSetting
.
displayOptionalInputMethod
().
then
(()
=>
{
console
.
info
(
"
displayOptionalInputMethod success.(promise)
"
);
console
.
info
(
"
displayOptionalInputMethod promise
"
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
"
displayOptionalInputMethod promise err:
"
+
err
);
console
.
info
(
"
displayOptionalInputMethod promise err:
"
+
err
);
})
});
}
```
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录