harmony 鸿蒙Common Event Callback
Common Event Callback
NOTE
The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.
UICommonEvent
Implements a common event callback. If the input parameter of an API is undefined, the corresponding event callback is reset.
setOnClick
setOnClick(callback: Callback<ClickEvent>|undefined): void
Set the callback for the click event.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
callback | Callback<ClickEvent> |undefined | Yes | Callback for the click event. |
setOnTouch
setOnTouch(callback: Callback<TouchEvent>|undefined): void
Sets the callback for the touch event.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
callback | Callback<TouchEvent> |undefined | Yes | Callback for the touch event. |
setOnAppear
setOnAppear(callback: Callback<void>|undefined): void
Sets the callback for the onAppear event.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
callback | Callback<void> |undefined | Yes | Callback for the onAppear event. |
setOnDisappear
setOnDisappear(callback: Callback<void>|undefined): void
Sets the callback for the onDisappear event.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
callback | Callback<void> |undefined | Yes | Callback for the onDisappear event. |
setOnKeyEvent
setOnKeyEvent(callback: Callback<KeyEvent>|undefined): void
Sets the callback for the key event.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
callback | Callback<KeyEvent> |undefined | Yes | Callback for the key event. |
setOnFocus
setOnFocus(callback: Callback<void>|undefined): void
Sets the callback for the onFocus event.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
callback | Callback<void> |undefined | Yes | Callback for the onFocus event. |
setOnBlur
setOnBlur(callback: Callback<void>|undefined): void
Sets the callback for the onBlur event.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
callback | Callback<void> |undefined | Yes | Callback for the onBlur event. |
setOnHover
setOnHover(callback: HoverCallback|undefined): void
Sets the callback for the onHover event.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
callback | HoverCallback |undefined | Yes | Callback for the onHover event. |
setOnMouse
setOnMouse(callback: Callback<MouseEvent>|undefined): void
Sets the callback for the onMouse event.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
callback | Callback<MouseEvent> |undefined | Yes | Callback for the onMouse event. |
setOnSizeChange
setOnSizeChange(callback: SizeChangeCallback|undefined): void
Sets the callback for the onSizeChange event.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
callback | SizeChangeCallback |undefined | Yes | Callback for the onSizeChange event. |
setOnVisibleAreaApproximateChange
setOnVisibleAreaApproximateChange(options: VisibleAreaEventOptions, event: VisibleAreaChangeCallback|undefined): void
Sets the onVisibleAreaChange callback that limits the callback interval.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
options | VisibleAreaEventOptions | Yes | Options of visible area changes. |
event | VisibleAreaChangeCallback |undefined | Yes | Callback for the onVisibleAreaChange event. Called when the ratio of the component’s visible area to its total area is greater than or less than the threshold. |
NOTE
This callback is not a real-time callback. The actual callback interval may be different from the expected interval. The interval between onVisibleAreaChange callbacks is greater than or equal to the expected update interval. If the expected interval set is too short, the actual callback interval is subject to the system load.
你可能感兴趣的鸿蒙文章
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦