Class sap.ui.unified.ColorPickerModule: sap/ui/unified/ColorPicker

extends Control

Enables the user to select a color. The color can be defined using HEX, RGB, or HSV values or a CSS color name.

Note: Keep in mind that this control needs either sap.m or sap.ui.commons library to be loaded in order to work as it depends on controls available in one or the other library.


Since: 1.48.0.
Constructor Summary
new sap.ui.unified.ColorPicker(sId?, mSettings?)Constructor for a new ColorPicker.
Event Summary
change(oControlEvent)Fired when the value is changed by user action.
liveChange(oControlEvent)Fired when the value is changed during the mouse move.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.ui.unified.ColorPicker.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.unified.ColorPicker with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.unified.ColorPicker.getMetadata()Returns a metadata object for class sap.ui.unified.ColorPicker.
attachChange(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the change event of this sap.ui.unified.ColorPicker.
attachLiveChange(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the liveChange event of this sap.ui.unified.ColorPicker.
detachChange(fnFunction, oListener)Detaches event handler fnFunction from the change event of this sap.ui.unified.ColorPicker.
detachLiveChange(fnFunction, oListener)Detaches event handler fnFunction from the liveChange event of this sap.ui.unified.ColorPicker.
fireChange(mParameters?)Fires event change to attached listeners.
fireLiveChange(mParameters?)Fires event liveChange to attached listeners.
getColorString()Gets current value of property colorString.
getMode()Gets current value of property mode.
getRGB()Gets current RGB values.
isColor(sColorString)Checks the validity of the CSS color string.
setColorString(sColorString)Sets a new value for property colorString.
setMode(sMode, bSuppressInvalidate)Setter for mode property.
Constructor Detail
new sap.ui.unified.ColorPicker(sId?, mSettings?)

Constructor for a new ColorPicker.

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject for a general description of the syntax of the settings object.

The supported settings are:

  • Properties

  • Aggregations

    • Events

      • change : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
      • liveChange : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

    In addition, all settings applicable to the base type sap.ui.core.Control can be used as well.

    Parameters:
    stringsId?ID for the new control, generated automatically if no ID is given
    objectmSettings?Initial settings for the new control
    Event Detail
    change(oControlEvent)

    Fired when the value is changed by user action.

    Note: When the user action is mouse dragging, the change event fires on the mouseup event.

    Parameters:
    sap.ui.base.EventoControlEvent
    sap.ui.base.EventProvideroControlEvent.getSource
    objectoControlEvent.getParameters
    intoControlEvent.getParameters.rParameter containing the RED value (0-255).
    intoControlEvent.getParameters.gParameter containing the GREEN value (0-255).
    intoControlEvent.getParameters.bParameter containing the BLUE value (0-255).
    intoControlEvent.getParameters.hParameter containing the HUE value (0-360).
    intoControlEvent.getParameters.sParameter containing the SATURATION value (0-100).
    intoControlEvent.getParameters.vParameter containing the VALUE value (0-100).
    intoControlEvent.getParameters.lParameter containing the LIGHTNESS value (0-100).
    stringoControlEvent.getParameters.hexParameter containing the Hexadecimal string (#FFFFFF).
    stringoControlEvent.getParameters.alphaParameter containing the alpha value (transparency).
    Since:
    1.48.0
    liveChange(oControlEvent)

    Fired when the value is changed during the mouse move.

    Note: When the user action is mouse move, the liveChange event is fired during the mousedown event.

    Parameters:
    sap.ui.base.EventoControlEvent
    sap.ui.base.EventProvideroControlEvent.getSource
    objectoControlEvent.getParameters
    intoControlEvent.getParameters.rParameter containing the RED value (0-255).
    intoControlEvent.getParameters.gParameter containing the GREEN value (0-255).
    intoControlEvent.getParameters.bParameter containing the BLUE value (0-255).
    intoControlEvent.getParameters.hParameter containing the HUE value (0-360).
    intoControlEvent.getParameters.sParameter containing the SATURATION value (0-100).
    intoControlEvent.getParameters.vParameter containing the VALUE value (0-100).
    intoControlEvent.getParameters.lParameter containing the LIGHTNESS value (0-100).
    stringoControlEvent.getParameters.hexParameter containing the Hexadecimal string (#FFFFFF).
    stringoControlEvent.getParameters.alphaParameter containing the alpha value (transparency).
    Since:
    1.48.0
    Method Detail
    sap.ui.unified.ColorPicker.extend(sClassName, oClassInfo?, FNMetaImpl?): function

    Creates a new subclass of class sap.ui.unified.ColorPicker with name sClassName and enriches it with the information contained in oClassInfo.

    oClassInfo might contain the same kind of information as described in sap.ui.core.Control.extend.

    Parameters:
    stringsClassNameName of the class being created
    objectoClassInfo?Object literal with information about the class
    functionFNMetaImpl?Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
    Returns:
    functionCreated class / constructor function
    sap.ui.unified.ColorPicker.getMetadata(): sap.ui.base.Metadata
    Returns a metadata object for class sap.ui.unified.ColorPicker.
    Returns:
    sap.ui.base.MetadataMetadata object describing this class
    attachChange(oData?, fnFunction, oListener?): sap.ui.unified.ColorPicker

    Attaches event handler fnFunction to the change event of this sap.ui.unified.ColorPicker.

    When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.unified.ColorPicker itself.

    Fired when the value is changed by user action.

    Note: When the user action is mouse dragging, the change event fires on the mouseup event.

    Parameters:
    objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
    functionfnFunctionThe function to be called when the event occurs
    objectoListener?Context object to call the event handler with. Defaults to this sap.ui.unified.ColorPicker itself
    Returns:
    sap.ui.unified.ColorPickerReference to this in order to allow method chaining
    Since:
    1.48.0
    attachLiveChange(oData?, fnFunction, oListener?): sap.ui.unified.ColorPicker

    Attaches event handler fnFunction to the liveChange event of this sap.ui.unified.ColorPicker.

    When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.unified.ColorPicker itself.

    Fired when the value is changed during the mouse move.

    Note: When the user action is mouse move, the liveChange event is fired during the mousedown event.

    Parameters:
    objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
    functionfnFunctionThe function to be called when the event occurs
    objectoListener?Context object to call the event handler with. Defaults to this sap.ui.unified.ColorPicker itself
    Returns:
    sap.ui.unified.ColorPickerReference to this in order to allow method chaining
    Since:
    1.48.0
    detachChange(fnFunction, oListener): sap.ui.unified.ColorPicker

    Detaches event handler fnFunction from the change event of this sap.ui.unified.ColorPicker.

    The passed function and listener object must match the ones used for event registration.

    Parameters:
    functionfnFunctionThe function to be called, when the event occurs
    objectoListenerContext object on which the given function had to be called
    Returns:
    sap.ui.unified.ColorPickerReference to this in order to allow method chaining
    Since:
    1.48.0
    detachLiveChange(fnFunction, oListener): sap.ui.unified.ColorPicker

    Detaches event handler fnFunction from the liveChange event of this sap.ui.unified.ColorPicker.

    The passed function and listener object must match the ones used for event registration.

    Parameters:
    functionfnFunctionThe function to be called, when the event occurs
    objectoListenerContext object on which the given function had to be called
    Returns:
    sap.ui.unified.ColorPickerReference to this in order to allow method chaining
    Since:
    1.48.0
    fireChange(mParameters?): sap.ui.unified.ColorPicker
    Fires event change to attached listeners.
    Parameters:
    objectmParameters?Parameters to pass along with the event
    intmParameters.r?Parameter containing the RED value (0-255).
    intmParameters.g?Parameter containing the GREEN value (0-255).
    intmParameters.b?Parameter containing the BLUE value (0-255).
    intmParameters.h?Parameter containing the HUE value (0-360).
    intmParameters.s?Parameter containing the SATURATION value (0-100).
    intmParameters.v?Parameter containing the VALUE value (0-100).
    intmParameters.l?Parameter containing the LIGHTNESS value (0-100).
    stringmParameters.hex?Parameter containing the Hexadecimal string (#FFFFFF).
    stringmParameters.alpha?Parameter containing the alpha value (transparency).
    Returns:
    sap.ui.unified.ColorPickerReference to this in order to allow method chaining
    Since:
    1.48.0
    fireLiveChange(mParameters?): sap.ui.unified.ColorPicker
    Fires event liveChange to attached listeners.
    Parameters:
    objectmParameters?Parameters to pass along with the event
    intmParameters.r?Parameter containing the RED value (0-255).
    intmParameters.g?Parameter containing the GREEN value (0-255).
    intmParameters.b?Parameter containing the BLUE value (0-255).
    intmParameters.h?Parameter containing the HUE value (0-360).
    intmParameters.s?Parameter containing the SATURATION value (0-100).
    intmParameters.v?Parameter containing the VALUE value (0-100).
    intmParameters.l?Parameter containing the LIGHTNESS value (0-100).
    stringmParameters.hex?Parameter containing the Hexadecimal string (#FFFFFF).
    stringmParameters.alpha?Parameter containing the alpha value (transparency).
    Returns:
    sap.ui.unified.ColorPickerReference to this in order to allow method chaining
    Since:
    1.48.0
    getColorString(): string

    Gets current value of property colorString.

    Determines the input parameter that can be a string of type HEX, RGB, HSV, or a CSS color name:

    • HEX - #FFFFFF
    • RGB - rgb(255,255,255)
    • HSV - hsv(360,100,100)
    • CSS - red

    Note: The output parameter is an RGB string of the current color.

    Returns:
    stringValue of property colorString
    Since:
    1.48.0

    Gets current value of property mode.

    Determines the color mode of the ColorPicker.

    Default value is HSV.

    Returns:
    sap.ui.unified.ColorPickerModeValue of property mode
    Since:
    1.48.0
    getRGB(): object
    Gets current RGB values.
    Returns:
    objectContaining current RGB values
    Since:
    1.48.0
    isColor(sColorString): boolean
    Checks the validity of the CSS color string.
    Parameters:
    stringsColorStringCSS color string to be validated
    Returns:
    booleanIf the passed string is a valid CSS color string
    Since:
    1.48.0
    setColorString(sColorString): sap.ui.unified.ColorPicker

    Sets a new value for property colorString.

    Determines the input parameter that can be a string of type HEX, RGB, HSV, or a CSS color name:

    • HEX - #FFFFFF
    • RGB - rgb(255,255,255)
    • HSV - hsv(360,100,100)
    • CSS - red

    Note: The output parameter is an RGB string of the current color.

    When called with a value of null or undefined, the default value of the property will be restored.

    Parameters:
    stringsColorStringNew value for property colorString
    Returns:
    sap.ui.unified.ColorPickerReference to this in order to allow method chaining
    Since:
    1.48.0
    setMode(sMode, bSuppressInvalidate)
    Setter for mode property.
    Parameters:
    sap.ui.unified.ColorPickerModesModecontrol mode enum
    booleanbSuppressInvalidateshould control invalidation be suppressed