harmony 鸿蒙ArkUI_NativeDialogAPI_1

  • 2025-06-12
  • 浏览 (4)

ArkUI_NativeDialogAPI_1

Overview

Provides the custom dialog box APIs for the native side.

Since: 12

Related module: ArkUI_NativeModule

Summary

Member Variables

Name Description
ArkUI_NativeDialogHandle(* create )() Creates a custom dialog box and returns the pointer to the created dialog box.
void(* dispose )(ArkUI_NativeDialogHandle handle) Destroys a custom dialog box.
int32_t(* setContent )(ArkUI_NativeDialogHandle handle, ArkUI_NodeHandle content) Sets the content for a custom dialog box.
int32_t(* removeContent )(ArkUI_NativeDialogHandle handle) Removes the content of a custom dialog box.
int32_t(* setContentAlignment )(ArkUI_NativeDialogHandle handle, int32_t alignment, float offsetX, float offsetY) Sets the alignment mode for a custom dialog box.
int32_t(* resetContentAlignment )(ArkUI_NativeDialogHandle handle) Resets the alignment mode of a custom dialog box to its default settings.
int32_t(* setModalMode )(ArkUI_NativeDialogHandle handle, bool isModal) Sets the modal mode for a custom dialog box.
int32_t(* setAutoCancel )(ArkUI_NativeDialogHandle handle, bool autoCancel) Specifies whether to allow users to touch the mask to dismiss the custom dialog box.
int32_t(* setMask )(ArkUI_NativeDialogHandle handle, uint32_t maskColor, const ArkUI_Rect *maskRect) Sets the mask for a custom dialog box.
int32_t(* setBackgroundColor )(ArkUI_NativeDialogHandle handle, uint32_t backgroundColor) Sets the background color for a custom dialog box.
int32_t(* setCornerRadius )(ArkUI_NativeDialogHandle handle, float topLeft, float topRight, float bottomLeft, float bottomRight) Sets the background corner radius for a custom dialog box.
int32_t(* setGridColumnCount )(ArkUI_NativeDialogHandle handle, int32_t gridCount) Number of grid columns occupied by the dialog box.
int32_t(* enableCustomStyle )(ArkUI_NativeDialogHandle handle, bool enableCustomStyle) Specifies whether to use a custom style for the custom dialog box.
int32_t(* enableCustomAnimation )(ArkUI_NativeDialogHandle handle, bool enableCustomAnimation) Specifies whether to use a custom animation for a custom dialog box.
int32_t(* registerOnWillDismiss )(ArkUI_NativeDialogHandle handle, ArkUI_OnWillDismissEvent eventHandler) Registers a callback for a custom dialog box so that the user can decide whether to close the dialog box after they touch the Back button or press the Esc key.
int32_t(* show )(ArkUI_NativeDialogHandle handle, bool showInSubWindow) Shows a custom dialog box.
int32_t(* close )(ArkUI_NativeDialogHandle handle) Closes a custom dialog box. If the dialog box has been closed, this API does not take effect.
int32_t(* registerOnWillDismissWithUserData )(ArkUI_NativeDialogHandle handle, void *userData, void(*callback)(ArkUI_DialogDismissEvent *event)) Registers a callback for the dismissal event of a custom dialog box.

Member Variable Description

close

int32_t(* ArkUI_NativeDialogAPI_1::close) (ArkUI_NativeDialogHandle handle)

Description

Closes a custom dialog box. If the dialog box has been closed, this API does not take effect.

Parameters

Name Description
handle Pointer to the custom dialog box controller.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

create

ArkUI_NativeDialogHandle(* ArkUI_NativeDialogAPI_1::create) ()

Description

Creates a custom dialog box and returns the pointer to the created dialog box.

NOTE

This method must be called before the show method.

Returns

Returns the pointer to the created custom dialog box; returns a null pointer if the creation fails.

dispose

void(* ArkUI_NativeDialogAPI_1::dispose) (ArkUI_NativeDialogHandle handle)

Description

Destroys a custom dialog box.

Parameters

Name Description
handle Pointer to the custom dialog box controller.

enableCustomAnimation

int32_t(* ArkUI_NativeDialogAPI_1::enableCustomAnimation) (ArkUI_NativeDialogHandle handle, bool enableCustomAnimation)

Description

Specifies whether to use a custom animation for a custom dialog box.

Parameters

Name Description
handle Pointer to the custom dialog box controller.
enableCustomAnimation Whether to use a custom animation. The value true means to use a custom animation, and false means to use the default animation.

NOTE

This method must be called before the show method.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

enableCustomStyle

int32_t(* ArkUI_NativeDialogAPI_1::enableCustomStyle) (ArkUI_NativeDialogHandle handle, bool enableCustomStyle)

Description

Specifies whether to use a custom style for the custom dialog box.

Parameters

Name Description
handle Pointer to the custom dialog box controller.
enableCustomStyle Whether to use a custom style for the dialog box.
true: The dialog box automatically adapts its width to the child components; the rounded corner is 0; the background color is transparent.
false: The dialog box automatically adapts its width to the grid system and its height to the child components; the rounded corner is 24 vp.

NOTE

This method must be called before the show method.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

registerOnWillDismiss

int32_t(* ArkUI_NativeDialogAPI_1::registerOnWillDismiss) (ArkUI_NativeDialogHandle handle, ArkUI_OnWillDismissEvent eventHandler)

Description

Registers a callback for a custom dialog box so that the user can decide whether to close the dialog box after they touch the Back button or press the Esc key.

Parameters

Name Description
handle Pointer to the custom dialog box controller.
eventHandler Callback to register. The parameter type is OnWillDismissEvent.

NOTE

This method must be called before the show method.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

registerOnWillDismissWithUserData

int32_t(* ArkUI_NativeDialogAPI_1::registerOnWillDismissWithUserData) (ArkUI_NativeDialogHandle handle, void *userData, void(*callback)(ArkUI_DialogDismissEvent *event))

Description

Registers a callback for the dismissal event of a custom dialog box.

Parameters

Name Description
handle Pointer to the custom dialog box controller.
userData Pointer to user data.
callback Callback for the dismissal event of the custom dialog box.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

removeContent

int32_t(* ArkUI_NativeDialogAPI_1::removeContent) (ArkUI_NativeDialogHandle handle)

Description

Removes the content of a custom dialog box.

Parameters

Name Description
handle Pointer to the custom dialog box controller.

NOTE

This method must be called before the show method.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

resetContentAlignment

int32_t(* ArkUI_NativeDialogAPI_1::resetContentAlignment) (ArkUI_NativeDialogHandle handle)

Description

Resets the alignment mode of a custom dialog box to its default settings.

Parameters

Name Description
handle Pointer to the custom dialog box controller.

NOTE

This method must be called before the show method.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

setAutoCancel

int32_t(* ArkUI_NativeDialogAPI_1::setAutoCancel) (ArkUI_NativeDialogHandle handle, bool autoCancel)

Description

Specifies whether to allow users to touch the mask to dismiss the custom dialog box.

Parameters

Name Description
handle Pointer to the custom dialog box controller.
autoCancel Whether to allow users to touch the mask to dismiss the dialog box. The value true means to allow users to do so, and false means the opposite.

NOTE

This method must be called before the show method.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

setBackgroundColor

int32_t(* ArkUI_NativeDialogAPI_1::setBackgroundColor) (ArkUI_NativeDialogHandle handle, uint32_t backgroundColor)

Description

Sets the background color for a custom dialog box.

Parameters

Name Description
handle Pointer to the custom dialog box controller.
backgroundColor Background color of the custom dialog box, in 0xARGB format.

NOTE

This method must be called before the show method.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

setContent

int32_t(* ArkUI_NativeDialogAPI_1::setContent) (ArkUI_NativeDialogHandle handle, ArkUI_NodeHandle content)

Description

Sets the content for a custom dialog box.

Parameters

Name Description
handle Pointer to the custom dialog box controller.
content Pointer to the root node of the custom dialog box content.

NOTE

This method must be called before the show method.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

setContentAlignment

int32_t(* ArkUI_NativeDialogAPI_1::setContentAlignment) (ArkUI_NativeDialogHandle handle, int32_t alignment, float offsetX, float offsetY)

Description

Sets the alignment mode for a custom dialog box.

Parameters

Name Description
handle Pointer to the custom dialog box controller.
alignment Alignment mode. The parameter type is ArkUI_Alignment.
offsetX Horizontal offset of the custom dialog box. The value is a floating point number.
offsetY Vertical offset of the custom dialog box. The value is a floating point number.

NOTE

This method must be called before the show method.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

setCornerRadius

int32_t(* ArkUI_NativeDialogAPI_1::setCornerRadius) (ArkUI_NativeDialogHandle handle, float topLeft, float topRight, float bottomLeft, float bottomRight)

Description

Sets the background corner radius for a custom dialog box.

Parameters

Name Description
handle Pointer to the custom dialog box controller.
topLeft Radius of the upper left corner of the custom dialog box background.
topRight Radius of the upper right corner of the custom dialog box background.
bottomLeft Radius of the lower left corner of the custom dialog box background.
bottomRight Radius of the lower right corner of the custom dialog box background.

NOTE

This method must be called before the show method.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

setGridColumnCount

int32_t(* ArkUI_NativeDialogAPI_1::setGridColumnCount) (ArkUI_NativeDialogHandle handle, int32_t gridCount)

Description

Sets the number of grid columns occupied by a custom dialog box.

Parameters

Name Description
handle Pointer to the custom dialog box controller.
gridCount Number of grid columns occupied by the dialog box. The default value is subject to the window size, and the maximum value is the maximum number of columns supported by the system.

NOTE

This method must be called before the show method.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

setMask

int32_t(* ArkUI_NativeDialogAPI_1::setMask) (ArkUI_NativeDialogHandle handle, uint32_t maskColor, const ArkUI_Rect *maskRect)

Description

Sets the mask for a custom dialog box.

Parameters

Name Description
handle Pointer to the custom dialog box controller.
maskColor Mask color, in 0xARGB format.
maskRect Pointer to the mask area. Events outside the mask area are transparently transmitted, and events within the mask area are not. The parameter type is ArkUI_Rect.

NOTE

This method must be called before the show method.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

setModalMode

int32_t(* ArkUI_NativeDialogAPI_1::setModalMode) (ArkUI_NativeDialogHandle handle, bool isModal)

Description

Sets the modal mode for a custom dialog box.

Parameters

Name Description
handle Pointer to the custom dialog box controller.
isModal Whether the custom dialog box is a modal, which has a mask applied. The value true means that the custom dialog box is a modal, and false means the opposite.

NOTE

This method must be called before the show method.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

show

int32_t(* ArkUI_NativeDialogAPI_1::show) (ArkUI_NativeDialogHandle handle, bool showInSubWindow)

Description

Shows a custom dialog box.

Parameters

Name Description
handle Pointer to the custom dialog box controller.
showInSubWindow Whether to show the dialog box in a subwindow.

Returns

Returns ARKUI_ERROR_CODE_NO_ERROR if the operation is successful. Returns ARKUI_ERROR_CODE_PARAM_INVALID if a parameter error occurs.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkUI

harmony 鸿蒙ARKUI_TextPickerCascadeRangeContent

harmony 鸿蒙ARKUI_TextPickerRangeContent

harmony 鸿蒙ArkUI_AnimateCompleteCallback

harmony 鸿蒙ArkUI_AttributeItem

harmony 鸿蒙ArkUI_ColorStop

harmony 鸿蒙ArkUI_ContextCallback

harmony 鸿蒙ArkUI_EventModule

harmony 鸿蒙ArkUI_ExpectedFrameRateRange

harmony 鸿蒙ArkUI_IntOffset

0  赞