輸入法框架
說明: 本模塊首批接口從API version 6開始支持。后續版本的新增接口,采用上角標單獨標記接口的起始版本。 開發前請熟悉鴻蒙開發指導文檔 :[
gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md
]
導入模塊
import inputMethod from '@ohos.inputMethod';
inputMethod8+
常量值。
系統能力 :以下各項對應的系統能力均為SystemCapability.Miscservices.InputMethodFramework
名稱 | 參數類型 | 可讀 | 可寫 | 說明 |
---|---|---|---|---|
MAX_TYPE_NUM | number | 是 | 否 | 可支持的最大輸入法個數。 |
InputMethodProperty8+
輸入法應用屬性。
系統能力 :以下各項對應的系統能力均為SystemCapability.Miscservices.InputMethodFramework
名稱 | 參數類型 | 可讀 | 可寫 | 說明 |
---|---|---|---|---|
packageName | string | 是 | 否 | 包名。 |
methodId | string | 是 | 否 | Ability名。 |
inputMethod.getInputMethodController
getInputMethodController(): InputMethodController
獲取客戶端實例[InputMethodController]。
系統能力 :SystemCapability.Miscservices.InputMethodFramework
返回值:
| 類型 | 說明 |
| -------- | -------- |
| [InputMethodController](#InputMethodController) | 回調返回當前客戶端實例。 |
示例:
var InputMethodController = inputMethod.getInputMethodController();
inputMethod.getInputMethodSetting8+
getInputMethodSetting(): InputMethodSetting
獲取客戶端設置實例[InputMethodSetting]。
系統能力 : SystemCapability.Miscservices.InputMethodFramework
返回值:
類型 | 說明 |
---|---|
[InputMethodSetting] | 回調返回當前客戶端設置實例。 |
示例:
var InputMethodSetting = inputMethod.getInputMethodSetting();
InputMethodController
下列API示例中都需使用[getInputMethodController]回調獲取到InputMethodController實例,再通過此實例調用對應方法。
stopInput
stopInput(callback: AsyncCallback): void
隱藏輸入法。
系統能力 :SystemCapability.Miscservices.InputMethodFramework
參數:
參數名 | 類型 | 必填 | 說明 |
---|---|---|---|
callback | AsyncCallback | 是 | 返回輸入法隱藏是否成功。 |
示例:
InputMethodController.stopInput((error)= >{
console.info('stopInput');
});
stopInput
stopInput(): Promise
隱藏輸入法。
系統能力 : SystemCapability.Miscservices.InputMethodFramework
返回值:
類型 | 說明 |
---|---|
Promise | 返回輸入法隱藏是否成功。 |
示例:
var isSuccess = InputMethodController.stopInput();
console.info('stopInput isSuccess = ' + isSuccess);
InputMethodSetting8+
下列API示例中都需使用[getInputMethodSetting]回調獲取到InputMethodSetting實例,再通過此實例調用對應方法。
listInputMethod
listInputMethod(callback: AsyncCallback>): void
查詢已安裝的輸入法列表。
系統能力 : SystemCapability.Miscservices.InputMethodFramework
參數:
參數名 | 類型 | 必填 | 說明 |
---|---|---|---|
callback | Array<[InputMethodProperty]> | 是 | 返回已安裝輸入法列表。 |
示例:
InputMethodSetting.listInputMethod((properties)= >{
for (var i = 0;i < properties.length; i++) {
var property = properties[i];
console.info(property.packageName + "/" + property.methodId);
}
});
listInputMethod
listInputMethod(): Array
查詢已安裝的輸入法列表。
系統能力 : SystemCapability.Miscservices.InputMethodFramework
返回值:
類型 | 說明 |
---|---|
Promise> | 返回已安裝輸入法列表。 |
示例:
var properties = InputMethodSetting.listInputMethod();
for (var i = 0;i < properties.length; i++) {
var property = properties[i];
console.info(property.packageName + "/" + property.methodId);
}
displayOptionalInputMethod
displayOptionalInputMethod(callback: AsyncCallback): void
顯示輸入法選擇對話框。
系統能力 : SystemCapability.Miscservices.InputMethodFramework
參數:
參數名 | 類型 | 必填 | 說明 |
---|---|---|---|
callback | AsyncCallback | 是 | 回調函數。 |
示例:
InputMethodSetting.displayOptionalInputMethod(()= >{
console.info('displayOptionalInputMethod is called');
});
displayOptionalInputMethod
displayOptionalInputMethod(): Promise
顯示輸入法選擇對話框。
系統能力 : SystemCapability.Miscservices.InputMethodFramework
返回值:
類型HarmonyOS與OpenHarmony鴻蒙文檔籽料:mau123789是v直接拿 | 說明 |
---|---|
Promise | 回調函數。 |
示例:
InputMethodSetting.displayOptionalInputMethod();
審核編輯 黃宇
-
接口
+關注
關注
33文章
8681瀏覽量
151600 -
框架
+關注
關注
0文章
403瀏覽量
17517 -
鴻蒙
+關注
關注
57文章
2384瀏覽量
42955
發布評論請先 登錄
相關推薦
【AWTK使用經驗】如何添加中文輸入法
![【AWTK使用經驗】如何添加中文<b class='flag-5'>輸入法</b>](https://file.elecfans.com/web2/M00/50/DA/pYYBAGLH6TyAB71EAAAPQ7KgtYA038.png)
在Labview中如何控制輸入法
Orange Pi 4開發板在Ubuntu系統下如何安裝中文輸入法
win10系統怎么禁用輸入法 兩種禁用輸入法的方法
【PIMF】OpenHarmony啃論文俱樂部——OpenHarmony標準系統上輸入法以及中文拼音輸入法原理
基于rk3399 9.0版本代碼在系統中默認百度輸入法并授予其所有權限
淺談輸入法編程
微信輸入法真的來了!百度輸入法、搜狗輸入法和訊飛會受影響嗎?
![微信<b class='flag-5'>輸入法</b>真的來了!百度<b class='flag-5'>輸入法</b>、搜狗<b class='flag-5'>輸入法</b>和訊飛會受影響嗎?](https://file.elecfans.com//web2/M00/85/1E/pYYBAGOgJqSAYLhUAAAkF4kXjyg572.jpg)
瑞芯微RK3566鴻蒙開發板Android11修改第三方輸入法為默認輸入法
![瑞芯微RK3566<b class='flag-5'>鴻蒙</b><b class='flag-5'>開發</b>板Android11修改第三方<b class='flag-5'>輸入法</b>為默認<b class='flag-5'>輸入法</b>](https://file1.elecfans.com/web2/M00/07/9D/wKgZombyGNqAJ2h0AAB5aXv3W1c207.png)
【AWTK使用經驗】如何使用系統輸入法與開啟最大化窗口功能
![【AWTK使用經驗】如何使用<b class='flag-5'>系統</b><b class='flag-5'>輸入法</b>與開啟最大化窗口功能](https://file.elecfans.com/web2/M00/50/DA/pYYBAGLH6TyAB71EAAAPQ7KgtYA038.png)
評論