Modal dialog component for asking users questions.
| Name | Type | Description |
|---|---|---|
options |
DialogOptions |
Configuration options for the dialog. |
options.backdrop |
string | Texture | Container | Sprite | Graphics |
Backdrop view or settings. |
options.backdropColor |
number |
Color of the backdrop (if backdrop is not provided). |
options.backdropAlpha |
number |
Alpha of the backdrop (if backdrop is not provided). |
options.background |
string | Texture | Container | Sprite | Graphics |
Background view or settings for the dialog. |
options.title |
string | Texture | Container | Sprite | Graphics |
Title text or settings for the dialog. |
options.content |
string | Texture | Container | Sprite | Graphics | Array<Container> |
Content text, view, or array of views for the dialog. |
options.width |
number |
Width of the dialog. |
options.height |
number |
Height of the dialog. |
options.padding |
number |
Padding around the dialog content. |
options.buttons |
unknown |
Array of button configurations or instances. |
options.buttonList |
ListOptions<Container> |
Configuration options for the button list layout. |
options.scrollBox |
ScrollBoxOptions |
Configuration options for the scroll box containing the content. |
options.animations |
object |
Animation settings for opening and closing the dialog. |
options.animations.open |
Animation |
Animation settings for opening the dialog. |
options.animations.close |
Animation |
Animation settings for closing the dialog. |
options.closeOnBackdropClick |
boolean |
Whether to close the dialog when clicking on the backdrop. |
options.nineSliceSprite |
unknown |
Nine-slice scaling settings for the background. |
Example
const dialog = new Dialog({
background: new Graphics().roundRect(0, 0, 400, 200, 20).fill(0xFFFFFF),
title: 'Confirm',
content: 'Are you sure?',
buttons: [
{ text: 'Cancel' },
{ text: 'OK' }
]
});
dialog.onSelect.connect((index, text) => {
console.log(`Button ${index} clicked: ${text}`);
});
dialog.open();
Extends
- Container
Members
Gets the open state of the dialog.
Signal emitted when the dialog is closed.
Signal emitted when a button is selected.
Gets the dialog height from options or innerView.
Gets the dialog padding from options.
Gets the dialog width from options or innerView.
Methods
Closes the dialog with animation.
Hides the dialog (alias for close).
Opens the dialog with animation.
Shows the dialog (alias for open).
Initializes the backdrop (semi-transparent background).
Initializes the buttons at the bottom of the dialog.
Initializes the content area, optionally wrapped in ScrollBox.
Initializes the inner view (background panel).
Initializes the title text if provided.