ColorDialog - Kirix Documentation

Developer Resources

ColorDialog

Overview

Class that represents a color chooser dialog.

Constructor

ColorDialog()

Methods

ColorDialog.getCaption
Gets the caption of the color dialog.
ColorDialog.getColor
Gets the color of the color dialog.
ColorDialog.getCustomColor
Gets a custom color from the color dialog.
ColorDialog.setCaption
Sets the caption for the color dialog.
ColorDialog.setColor
Sets the color of the color dialog.
ColorDialog.setCustomColor
Sets a custom color in the color dialog.
ColorDialog.showAllColors
Sets a flag to show either a full color dialog or a basic color dialog.
ColorDialog.showDialog
Shows the color dialog.

Example

// create a new color dialog that shows the extended
// color selector
var dlg = new ColorDialog;
dlg.showAllColors();

// add some custom colors to the dialog
dlg.setCustomColor(0, new Color(200, 0, 0)); // custom red
dlg.setCustomColor(1, 0, 0, 200);            // custom blue

// show the dialog, and if the user selects a color,
// display a message that shows the RGB values of
// the selected color

if (dlg.showDialog() == DialogResult.Ok)
{
    // the getColor() funtion returns a Color object,
    // which has red, green, and blue members
    var c = dlg.getColor();

    // extract the red, green, and blue values
    // from the color object and display them
    // with an alert
    var output = "";
    output += "Red: " + c.red + "\n";
    output += "Green: " + c.green + "\n";
    output += "Blue: " + c.blue + "\n";
    alert(output);
}

ColorDialog.getCaption

function ColorDialog.getCaption() : String

Returns

Returns the caption of the color dialog.

Description

Returns the caption of the color dialog.

ColorDialog.getColor

function ColorDialog.getColor() : Color

Returns

Returns the color object that corresponds to the currently set color of the color dialog.

Description

Returns the color object that corresponds to the currently set color of the color dialog.

ColorDialog.getCustomColor

function ColorDialog.getCustomColor(index : Integer) : Color

Arguments

index
The index of the custom color to return.

Returns

Returns the custom color object for the specified index, where index is between 0 and 15.

Description

Returns the custom color object for the specified index, where index is between 0 and 15.

ColorDialog.setCaption

function ColorDialog.setCaption(text : String)

Arguments

text
The text to which to set the caption of the color dialog.

Description

Sets the caption of the color dialog to text.

ColorDialog.setColor

function ColorDialog.setColor(color : Color)
function ColorDialog.setColor(red : Integer, green : Integer, blue : Integer)

Arguments

color
The color object to which to set the dialog's color.
red
The red value of the color to which to set the dialog's color.
green
The green value of the color to which to set the dialog's color.
blue
The blue value of the color to which to set the dialog's color.

Description

Sets the color of the color dialog to the value specified by color or to the values specified by red, green, and blue.

ColorDialog.setCustomColor

function ColorDialog.setCustomColor(index : Integer) color : Color)
function ColorDialog.setCustomColor(index : Integer, red : Integer, green : Integer, blue : Integer)

Arguments

index
The index of the custom color to set, where index is between 0 and 15.
color
The color object to which to set the custom color.
red
The red value of the color to which to set the custom color.
green
The green value of the color to which to set the custom color.
blue
The blue value of the color to which to set the custom color.

Description

Sets the custom color with the given index, where index is between 0 and 15, to the color specified by color or to the values specified by red, green, and blue.

ColorDialog.showAllColors

function ColorDialog.showAllColors(flag : Boolean)

Arguments

flag
A flag to determine whether to show a full color dialog, or a basic color dialog.

Description

Sets a flag to show either a full color dialog or a basic color dialog. If flag is true, a full color dialog will be shown. If flag is false, a basic color dialog will be shown.

ColorDialog.showDialog

function ColorDialog.showDialog() : Boolean

Returns

Returns DialogResult.Ok when the dialog is closed by pressing "OK" or equivalent, and DialogResult.Cancel if the dialog is closed by pressing "Cancel" or equivalent.

Description

Shows a color dialog and returns DialogResult.Ok if the user closes the color dialog by pressing "OK", or the equivalent, and DialogResult.Cancel if the user closes the color dialog by pressing "Cancel", or the equivalent.