harmony 鸿蒙@ohos.inputMethodEngine (Input Method Service) (System API)
@ohos.inputMethodEngine (Input Method Service) (System API)
The inputMethodEngine module provides management capabilities for system input method applications. With the APIs of this module, input method applications are able to create soft keyboard windows, insert or delete characters, select text, and listen for physical keyboard events.
NOTE
The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Modules to Import
import { inputMethodEngine } from '@kit.IMEKit';
SizeUpdateCallback14+
type SizeUpdateCallback = (size: window.Size, keyboardArea: KeyboardArea) => void
Callback triggered when the size of the input method panel changes.
System capability: SystemCapability.MiscServices.InputMethodFramework
System API: This is a system API.
Name | Type | Mandatory | Description |
---|---|---|---|
size | window.Size | Yes | Panel size. |
keyboardArea | KeyboardArea | Yes | Size of the keyboard area. |
Panel10+
You need to use createPanel to obtain the panel instance and then call the following APIs through the instance.
on(‘sizeUpdate’)14+
on(type: ‘sizeUpdate’, callback: SizeUpdateCallback): void
Listens for the panel size change. This API uses an asynchronous callback to return the result.
NOTE
This API applies only to the panels of the SOFT_KEYBOARD type in the FLG_FIXED or FLG_FLOATING state. When you call adjustPanelRect to adjust the panel size, the system calculates the final value based on certain rules (for example, whether the panel size exceeds the screen). This callback can be used to obtain the actual panel size to refresh the panel layout.
System capability: SystemCapability.MiscServices.InputMethodFramework
System API: This is a system API.
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
type | string | Yes | Event type, which is ‘sizeUpdate’. |
callback | SizeUpdateCallback | Yes | Callback used to return the result, the size of the soft keyboard panel, including the width and height. |
Example
import { window } from '@kit.ArkUI';
try {
panel.on('sizeUpdate', (windowSize: window.Size, keyboardArea: inputMethodEngine.KeyboardArea) => {
console.info(`panel size changed, windowSize: ${JSON.stringify(windowSize)}, keyboardArea: ${JSON.stringify(keyboardArea)}`);
});
} catch(err) {
console.error(`Failed to subscribe sizeUpdate: ${JSON.stringify(err)}`);
}
off(‘sizeUpdate’)14+
off(type: ‘sizeUpdate’, callback?: SizeUpdateCallback): void
Disables listening for the panel size change. This API uses an asynchronous callback to return the result.
NOTE
This API applies only to the panels of the SOFT_KEYBOARD type in the FLG_FIXED or FLG_FLOATING state. When you call adjustPanelRect to adjust the panel size, the system calculates the final value based on certain rules (for example, whether the panel size exceeds the screen). This callback can be used to obtain the actual panel size to refresh the panel layout.
System capability: SystemCapability.MiscServices.InputMethodFramework
System API: This is a system API.
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
type | string | Yes | Event type, which is ‘sizeUpdate’. |
callback | SizeUpdateCallback | No | Callback used to return the result, the size of the soft keyboard panel, including the width and height. |
Example
import { window } from '@kit.ArkUI';
try {
panel.off('sizeUpdate', (windowSize: window.Size, keyboardArea: inputMethodEngine.KeyboardArea) => {
console.info(`panel size changed, width: ${windowSize.width}, height: ${windowSize.height}`);
});
} catch(err) {
console.error(`Failed to subscribe sizeUpdate: ${JSON.stringify(err)}`);
}
你可能感兴趣的鸿蒙文章
harmony 鸿蒙Input Method Framework Error Codes
harmony 鸿蒙inputmethod_attach_options_capi.h
harmony 鸿蒙inputmethod_controller_capi.h
harmony 鸿蒙inputmethod_cursor_info_capi.h
harmony 鸿蒙inputmethod_inputmethod_proxy_capi.h
harmony 鸿蒙inputmethod_private_command_capi.h
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦