User Tools

Site Tools


en:code:windows:messagebox

MessageBox

This object represents a window showing some text to the user.

Functions

MessageBox

Constructor function.

Syntax

var myObject = new MessageBox();
var myObject = new MessageBox(parameters);

Arguments

  1. parameters - (object) window parameters
    • title - (string) the window's title
    • position - (Point) the window's position
    • opacity - (float) the window's opacity
    • enabled - (boolean) the window's enabled status
    • visible - (boolean) the window's visible status
    • text - (string) the text
    • detailedText - (string) the detailed text
    • informativeText - (string) the informative text (appended to text)
    • buttons - (StandardButton) a flag list of buttons
    • icon - (Icon) the number of decimals
    • defaultButton - (StandardButton) the default selected button
    • escapeButton - (StandardButton) the button pressed when pressing escape
    • onClosed - (OnClosed) event called when the window is closed

Exceptions

  • (ParameterTypeError) incorrect parameter type
  • (ParameterCountError) incorrect parameter count

Example

var myObject = new MessageBox();
var myObject = new MessageBox({
	title: "Press yes or no",
	icon: MessageBox.Warning,
	buttons: MessageBox.Yes | MessageBox.No
});

Methods

setTitle

Sets the window's title.

Syntax

myObject.setTitle(title);

Arguments

  1. title - (string) the window's title

Returns

  • (MessageBox) this MessageBox

setPosition

Sets the window's position.

Syntax

myObject.setPosition(point);

Arguments

  1. point - (Point) the window's position

Returns

  • (MessageBox) this MessageBox

setOpacity

Sets the window's opacity.

Syntax

myObject.setOpacity(opacity);

Arguments

  1. opacity - (float) the window's opacity

Returns

  • (MessageBox) this MessageBox

setEnabled

Sets the window's enabled status.

Syntax

myObject.setEnabled(enabled);

Arguments

  1. enabled - (boolean) the window's enabled status

Returns

  • (MessageBox) this MessageBox

setVisible

Sets the window's visible status.

Syntax

myObject.setVisible(visible);

Arguments

  1. visible - (boolean) the window's visible status

Returns

  • (MessageBox) this MessageBox

close

Closes the window.

Syntax

myObject.close();

Returns

  • (MessageBox) this MessageBox

title

Returns the window's title.

Syntax

myObject.title();

Returns

  • (string) the window's title

position

Returns the window's position.

Syntax

myObject.position();

Returns

  • (Point) the window's position

opacity

Returns the window's opacity.

Syntax

myObject.opacity();

Returns

  • (float) the window's opacity

enabled

Returns the window's enabled status.

Syntax

myObject.enabled();

Returns

  • (boolean) the window's enabled status

visible

Returns the window's visible status.

Syntax

myObject.visible();

Returns

  • (boolean) the window's visible status

setText

Sets the text.

Syntax

myObject.setText(text);

Arguments

  1. text - (string) the text

Returns

  • (MessageBox) this MessageBox

setDetailedText

Sets the detailed text.

Syntax

myObject.setDetailedText(detailedText);

Arguments

  1. detailedText - (string) the detailed text

Returns

  • (MessageBox) this MessageBox

setInformativeText

Sets the informative text (appended to text).

Syntax

myObject.setInformativeText(informativeText);

Arguments

  1. informativeText - (string) the informative text

Returns

  • (MessageBox) this MessageBox

setButtons

Sets the buttons to use.

Syntax

myObject.setButtons(buttons);

Arguments

  1. buttons - (StandardButton) the buttons to use (flag)

Returns

  • (MessageBox) this MessageBox

setIcon

Sets the icon to use.

Syntax

myObject.setIcon(icon);

Arguments

  1. buttons - (Icon) the icon to use

Returns

  • (MessageBox) this MessageBox

setDefaultButton

Sets the default selected button.

Syntax

myObject.setDefaultButton(button);

Arguments

  1. button - (StandardButton) the default button

Returns

  • (MessageBox) this MessageBox

setEscapeButton

Sets the button pressed when pressing the escape key.

Syntax

myObject.setEscapeButton(button);

Arguments

  1. button - (StandardButton) the button pressed when pressing the escape key

Returns

  • (MessageBox) this MessageBox

addCustomButton

Adds a custom button.

Syntax

myObject.addCustomButton(button, text);

Arguments

  1. button - (StandardButton) the standard button corresponding to this custom button
  2. text - (string) the text of this button

Returns

  • (MessageBox) this MessageBox

Exceptions

  • (AddCustomButtonError) add custom button failed

show

Show the window. (non-blocking) Use the OnClosed event to know when the window has been closed.

Syntax

myObject.show();

Returns

  • (MessageBox) this MessageBox

showModal

Show the window. (blocking)

Syntax

myObject.showModal();

Returns

  • (integer) the window result (0 means that it has been canceled)

Events

onClosed

Called when the window is closed.

Syntax

myObject.onClosed = function(result) {};

Arguments

  1. result - (integer) the window result (0 means that it has been canceled)

Example

myObject.onClosed = function(result)
{
	if(result)
	{
		//Event action
	}
};

Attributes

title

The window's title. (string)

position

The window's position. (Point)

opacity

The window's opacity. (float)

enabled

The window's enabled status. (boolean)

visible

The window's visible status. (boolean)

Enumerations

StandardButton

A standard button.

Values

  1. Ok: an "ok" button
  2. Open: an "open" button
  3. Save: a "save" button
  4. Cancel: a "cancel" button
  5. Close: a "close" button
  6. Discard: a "discard" button
  7. Apply: an "apply" button
  8. Reset: a "reset" button
  9. RestoreDefaults: a "restore defaults" button
  10. Help: a "help" button
  11. SaveAll: a "save all" button
  12. Yes: a "yes" button
  13. YesToAll: a "yes to all" button
  14. No: a "no" button
  15. NoToAll: a "no to all" button
  16. Abort: an "abort" button
  17. Retry: a "retry" button
  18. Ignore: an "ignore" button
  19. NoButton: no button

Notes

This is a flag enumeration, this means that you can use multiple values using the | operator. Example :

myObject.setButtons(MessageBox.Yes | MessageBox.Save); //Show yes and save buttons

Icon

An icon.

Values

  1. NoIcon: no icon
  2. Question: a question mark icon
  3. Information: an information icon
  4. Warning: a warning icon
  5. Critical: a critical icon (error)
en/code/windows/messagebox.txt · Last modified: 2016/10/09 11:10 (external edit)