Back

showColorPicker

JS Py
Hello World
Content:
- Examples
- Properties
- Methods

Shows a color picker.

cpk = ui.showColorPicker( value?, options?, onSelect? ) → ui object: ColorPicker

Here are the available methods of the ColorPicker Component.

Examples

Example - Basic

class Main extends App
{
    onStart()
    {
        // Create a fullscreen layout with objects vertically centered
        this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")

        // Add a button to the main layout
        this.btn = ui.addButton(this.main, "Show Popup", "Primary")

        // Add callback handler for `onTouch` event
        this.btn.setOnTouch( this.showColorPicker )
    }

    showColorPicker()
    {
        // Show color picker dialog with `Alpha` option
        // to include alpha in the output format `#aarrggbb`
        ui.showColorPicker(null, "Alpha", this.onSelect)
    }

    onSelect( clr )
    {
        ui.showPopup( clr )
    }
}
from hybrid import ui

def OnStart():
    # Create a fullscreen layout with objects vertically centered
    main = ui.addLayout("main", "Linear", "VCenter,FillXY")

    # Add a button to the main layout
    btn = ui.addButton(main, "Show Popup", "Primary")

    # Add callback handler for `onTouch` event
    btn.setOnTouch(showColorPicker)

def showColorPicker(event):
    # Show color picker dialog with `Alpha` option
    # to include alpha in the output format `#aarrggbb`
    ui.showColorPicker(None, "Alpha", onSelect)

def onSelect(clr):
    ui.showPopup(clr)
Copy All       Run      

Properties

The following properties are available on the ColorPicker object:

valueString

Methods

The following methods are available on the ColorPicker object:

getValue() → String
String: “A hexadecimal default value for the color picker.”
String: “A comma separated options.
Includes alpha: `Alpha`”
function( value )
cpk.getValue
Returns the hexadecimal string color value of the color picker.
cpk.value
Returns the value of the chosen color.