Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
99446037
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看板
未验证
提交
99446037
编写于
9月 05, 2023
作者:
O
openharmony_ci
提交者:
Gitee
9月 05, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23976 输入法框架,同步master到0815分支
Merge pull request !23976 from guojin31/monthly_20230815
上级
ec39704f
f158a6ee
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
864 addition
and
477 deletion
+864
-477
zh-cn/application-dev/application-models/inputmethodextentionability.md
...ion-dev/application-models/inputmethodextentionability.md
+26
-34
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-ability.md
...v/reference/apis/js-apis-inputmethod-extension-ability.md
+8
-5
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-context.md
...v/reference/apis/js-apis-inputmethod-extension-context.md
+14
-7
zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md
...ication-dev/reference/apis/js-apis-inputmethod-subtype.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
+189
-172
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
...plication-dev/reference/apis/js-apis-inputmethodengine.md
+626
-258
未找到文件。
zh-cn/application-dev/application-models/inputmethodextentionability.md
浏览文件 @
99446037
...
...
@@ -61,29 +61,30 @@
export
default
class
InputDemoService
extends
InputMethodExtensionAbility
{
onCreate
(
want
:
Want
)
{
keyboardController
.
onCreate
(
this
.
context
);
// 初始化窗口并注册对输入法框架的事件监听
onCreate
(
want
:
Want
)
:
void
{
keyboardController
.
onCreate
(
this
.
context
);
// 初始化窗口并注册对输入法框架的事件监听
}
onDestroy
()
{
onDestroy
()
:
void
{
console
.
log
(
"
onDestroy.
"
);
this
.
keyboardController
.
onDestroy
();
// 销毁窗口并去注册事件监听
keyboardController
.
onDestroy
();
// 销毁窗口并去注册事件监听
}
}
```
2.
KeyboardController.ts文件。
```
ts
import
common
from
'
@ohos.app.ability.common
'
;
import
inputMethodEngine
from
'
@ohos.inputMethodEngine
'
;
import
display
from
'
@ohos.display
'
;
import
inputMethodEngine
from
'
@ohos.inputMethodEngine
'
;
import
InputMethodExtensionContext
from
'
@ohos.InputMethodExtensionContext
'
;
// 调用输入法框架的getInputMethodAbility方法获取实例,并由此实例调用输入法框架功能接口
const
inputMethodAbility
:
inputMethodEngine
.
InputMethodAbility
=
inputMethodEngine
.
getInputMethodAbility
();
export
class
KeyboardController
{
private
mContext
:
common
.
ExtensionContext
|
undefined
=
undefined
;
// 保存InputMethodExtensionAbility中的context属性
private
mContext
:
InputMethod
ExtensionContext
|
undefined
=
undefined
;
// 保存InputMethodExtensionAbility中的context属性
private
panel
:
inputMethodEngine
.
Panel
|
undefined
=
undefined
;
private
textInputClient
:
inputMethodEngine
.
InputClient
|
undefined
=
undefined
;
private
keyboardController
:
inputMethodEngine
.
KeyboardController
|
undefined
=
undefined
;
...
...
@@ -91,20 +92,23 @@
constructor
()
{
}
public
onCreate
(
context
:
common
.
ExtensionContext
):
void
public
onCreate
(
context
:
InputMethod
ExtensionContext
):
void
{
this
.
mContext
=
context
;
this
.
initWindow
();
// 初始化窗口
this
.
registerListener
();
// 注册对输入法框架的事件监听
this
.
initWindow
();
// 初始化窗口
this
.
registerListener
();
// 注册对输入法框架的事件监听
}
public
onDestroy
():
void
// 应用生命周期销毁
public
onDestroy
():
void
// 应用生命周期销毁
{
this
.
unRegisterListener
();
// 去注册事件监听
this
.
unRegisterListener
();
// 去注册事件监听
if
(
this
.
panel
)
{
// 销毁窗口
this
.
panel
.
hide
();
inputMethodAbility
.
destroyPanel
(
this
.
panel
);
}
if
(
this
.
mContext
)
{
this
.
mContext
.
destroy
();
}
}
public
insertText
(
text
:
string
):
void
{
...
...
@@ -119,7 +123,7 @@
}
}
private
initWindow
():
void
// 初始化窗口
private
initWindow
():
void
// 初始化窗口
{
if
(
this
.
mContext
===
undefined
)
{
return
;
...
...
@@ -146,18 +150,18 @@
private
registerListener
():
void
{
this
.
registerInputListener
();
// 注册对输入法框架服务的监听
this
.
registerInputListener
();
// 注册对输入法框架服务的监听
...
// 注册隐藏键盘事件监听等
}
private
registerInputListener
():
void
{
// 注册对输入法框架服务的开启及停止事件监听
private
registerInputListener
():
void
{
// 注册对输入法框架服务的开启及停止事件监听
inputMethodAbility
.
on
(
'
inputStart
'
,
(
kbController
,
textInputClient
)
=>
{
this
.
textInputClient
=
textInputClient
;
// 此为输入法客户端实例,由此调用输入法框架提供给输入法应用的功能接口
this
.
boardController
=
kbController
;
this
.
textInputClient
=
textInputClient
;
// 此为输入法客户端实例,由此调用输入法框架提供给输入法应用的功能接口
this
.
key
boardController
=
kbController
;
})
inputMethodAbility
.
on
(
'
inputStop
'
,
()
=>
{
this
.
onDestroy
();
// 销毁KeyboardController
this
.
onDestroy
();
// 销毁KeyboardController
});
}
...
...
@@ -166,18 +170,6 @@
inputMethodAbility
.
off
(
'
inputStart
'
);
inputMethodAbility
.
off
(
'
inputStop
'
,
()
=>
{});
}
private
async
showHighWindow
():
Promise
<
void
>
{
try
{
if
(
this
.
panel
)
{
await
this
.
panel
.
resize
(
this
.
windowWidth
,
this
.
windowHeight
);
await
this
.
panel
.
moveTo
(
0
,
this
.
nonBarPosition
);
await
this
.
panel
.
show
();
}
}
catch
(
e
)
{
console
.
log
(
'
err occur:
'
+
JSON
.
stringify
(
e
));
}
}
}
const
keyboardController
=
new
KeyboardController
();
...
...
@@ -240,7 +232,7 @@
@Component
struct keyItem {
private keyValue: sourceListType
private keyValue: sourceListType
= numberSourceListData[0];
@State keyBgc: string = "#fff"
@State keyFontColor: string = "#000"
...
...
@@ -291,9 +283,9 @@
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceEvenly }) {
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
ForEach(this.numberList, (item: sourceListType) => {
// 数字键盘第一行
ForEach(this.numberList, (item: sourceListType) => { // 数字键盘第一行
keyItem({ keyValue: item })
}, (item: sourceListType)
: sourceListType
=> item.content);
}, (item: sourceListType) => item.content);
}
.padding({ top: "2%" })
.width("96%")
...
...
@@ -339,7 +331,7 @@
}
}
```
5.
在工程Module对应的
[
module.json5配置文件
](
../quick-start/module-configuration-file.md
)
中注册InputMethodExtensionAbility,type标签需要设置为“inputMethod”,srcEntry标签表示当前InputMethodExtensionAbility组件所对应的代码路径。
```
json
...
...
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-ability.md
浏览文件 @
99446037
...
...
@@ -8,7 +8,7 @@
## 导入模块
```
j
s
```
t
s
import
InputMethodExtensionAbility
from
'
@ohos.InputMethodExtensionAbility
'
;
```
...
...
@@ -36,9 +36,11 @@ Extension生命周期回调,在拉起Extension输入法应用时调用,执
**示例:**
```
js
```
ts
import
InputMethodExtensionAbility
from
'
@ohos.InputMethodExtensionAbility
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
class
InputMethodExt
extends
InputMethodExtensionAbility
{
onCreate
(
want
)
{
onCreate
(
want
:
Want
):
void
{
console
.
log
(
'
onCreate, want:
'
+
want
.
abilityName
);
}
}
...
...
@@ -54,9 +56,10 @@ Extension生命周期回调,在销毁输入法应用时回调,执行资源
**示例:**
```
js
```
ts
import
InputMethodExtensionAbility
from
'
@ohos.InputMethodExtensionAbility
'
;
class
InputMethodExt
extends
InputMethodExtensionAbility
{
onDestroy
()
{
onDestroy
()
:
void
{
console
.
log
(
'
onDestroy
'
);
}
}
...
...
zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-context.md
浏览文件 @
99446037
...
...
@@ -8,7 +8,7 @@ InputMethodExtensionContext模块是InputMethodExtensionAbility的上下文环
## 导入模块
```
```
ts
import
InputMethodExtensionContext
from
'
@ohos.InputMethodExtensionContext
'
;
```
...
...
@@ -16,10 +16,11 @@ import InputMethodExtensionContext from '@ohos.InputMethodExtensionContext';
在使用InputMethodExtensionContext的功能前,需要通过InputMethodExtensionAbility子类实例获取。
```
j
s
```
t
s
import
InputMethodExtensionAbility
from
'
@ohos.InputMethodExtensionAbility
'
;
class
EntryAbility
extends
InputMethodExtensionAbility
{
onCreate
()
{
import
Want
from
'
@ohos.app.ability.Want
'
;
class
InputMethodExtnAbility
extends
InputMethodExtensionAbility
{
onCreate
(
want
:
Want
):
void
{
let
context
=
this
.
context
;
}
}
...
...
@@ -41,8 +42,12 @@ destroy(callback: AsyncCallback\<void>): void
**示例:**
```
js
this
.
context
.
destroy
(()
=>
{
```
ts
this
.
context
.
destroy
((
err
:
Error
)
=>
{
if
(
err
)
{
console
.
log
(
'
Failed to destroy context.
'
);
return
;
}
console
.
log
(
'
Succeeded in destroying context.
'
);
});
```
...
...
@@ -63,8 +68,10 @@ destroy(): Promise\<void>;
**示例:**
```
j
s
```
t
s
this
.
context
.
destroy
().
then
(()
=>
{
console
.
log
(
'
Succeed in destroying context.
'
);
}).
catch
((
err
:
Error
)
=>
{
console
.
log
(
'
Failed to destroy context.
'
);
});
```
zh-cn/application-dev/reference/apis/js-apis-inputmethod-subtype.md
浏览文件 @
99446037
...
...
@@ -8,7 +8,7 @@
## 导入模块
```
```
ts
import
InputMethodSubtype
from
'
@ohos.InputMethodSubtype
'
;
```
...
...
zh-cn/application-dev/reference/apis/js-apis-inputmethod.md
浏览文件 @
99446037
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md
浏览文件 @
99446037
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录