Canvas Toolkit
← Class index

CMessageBox

Dialogs · extends CDialog

Dialog for displaying short messages with standard response buttons.

import { CMessageBox } from "canvas-toolkit-lib";

Declared members

static readonly DefaultWidth = 360;
static readonly DefaultHeight = 130;
static readonly Margin = 12;
static readonly Spacing = 8;
readonly buttonClicked: CSignal<[CStandardButton]>;

Emitted when a standard button is clicked.

constructor(parent?: CWidget | null);

Creates a message box. @param parent Optional parent widget.

text(): string;

Returns the primary message text. @returns Primary message text.

setText(text: string): void;

Sets the primary message text. @param text Message text.

informativeText(): string;

Returns the additional informative text. @returns Informative text.

setInformativeText(text: string): void;

Sets the additional informative text. @param text Informative text; an empty string hides it.

icon(): CMessageBoxIcon;

Returns the message icon type. @returns Current icon type.

setIcon(icon: CMessageBoxIcon): void;

Sets the message icon type. @param icon Icon type to display.

standardButtons(): CStandardButton;

Returns the configured standard buttons. @returns Bitwise combination of standard buttons.

setStandardButtons(buttons: CStandardButton): void;

Sets the standard response buttons. @param buttons Bitwise combination of buttons.

clickedButton(): CStandardButton;

Returns the last activated standard button. @returns Last clicked button, or `NoButton` if none.

static information(parent: CWidget | null, title: string, text: string, buttons?: CStandardButton): CMessageBox;

Shows an informational message box. @param parent Optional parent widget. @param title Dialog title. @param text Message text. @param buttons Bitwise combination of response buttons. @returns The opened message box instance.

static warning(parent: CWidget | null, title: string, text: string, buttons?: CStandardButton): CMessageBox;

Shows a warning message box. @param parent Optional parent widget. @param title Dialog title. @param text Message text. @param buttons Bitwise combination of response buttons. @returns The opened message box instance.

static critical(parent: CWidget | null, title: string, text: string, buttons?: CStandardButton): CMessageBox;

Shows a critical-error message box. @param parent Optional parent widget. @param title Dialog title. @param text Message text. @param buttons Bitwise combination of response buttons. @returns The opened message box instance.

static question(parent: CWidget | null, title: string, text: string, buttons?: number): CMessageBox;

Shows a question message box. @param parent Optional parent widget. @param title Dialog title. @param text Message text. @param buttons Bitwise combination of response buttons. @returns The opened message box instance.

open(): void;

Opens the message box and resets the clicked-button state.