ColorPicker

Regular state

Opened state

An element which is designed to select a color in RGB format without an alpha channel

Create from source

func NewColorPicker(session Session, params Params) ColorPicker

Create new color picker object and returns its interface

Create from resource

ColorPicker {
    id = colorPicker,
}

Interface description

Inherit methods, properties and events from View

Properties

"color-picker-value"

Define current color picker value

Constant: ColorPickerValue

Types: Color, string

Internal type is Color, other types converted to it during assignment

See Color description for more details

Examples

ColorPicker {
    color-picker-value = #FFBEBEBE,
}
ColorPicker {
    color-picker-value = "argb(255, 128, 96, 0)",
}
picker := rui.NewColorPicker(session, rui.Params{
    rui.ColorPickerValue: 0xFFBEBEBE,
})
picker := rui.NewColorPicker(session, rui.Params{
    rui.ColorPickerValue: "#FFBEBEBE",
})

"data-list"

List of pre-defined colors

Constant: DataList

Types: []string, string, []fmt.Stringer, []Color, []SizeUnit, []AngleUnit, []any containing elements of string, fmt.Stringer, bool, rune, float32, float64, int, int8int64, uint, uint8uint64

Internal type is []string, other types converted to it during assignment

Conversion rules

string - contain single item

[]string - an array of items

[]fmt.Stringer - an array of objects convertible to a string

[]Color - An array of color values which will be converted to a string array

[]SizeUnit - an array of size unit values which will be converted to a string array

[]any - this array must contain only types which were listed in Types section

Examples

ColorPicker {
    data-list = [
        #FFFF1010,
        #FF10FF10,
        #FF1010FF,
    ]
}
picker := rui.NewColorPicker(session, rui.Params{
    rui.DataList: []string {
        "#FFFF1010",
        "#FF10FF10",
        "#FF1010FF",
    },
})

Events

"color-changed"

Event generated when color picker value has been changed

Constant: ColorChangedEvent

General listener format:

func(picker rui.ColorPicker, newColor, oldColor rui.Color)

where: * picker - Interface of a color picker which generated this event * newColor - New color value * oldColor - Old color value

Allowed listener formats:

func(picker rui.ColorPicker, newColor rui.Color)

func(newColor, oldColor rui.Color)

func(newColor rui.Color)

func(picker rui.ColorPicker)

func()

func ColorPickerByID(rootView View, id string) ColorPicker

Return a ColorPicker with id equal to the argument of the function or nil if there is no such View or View is not a ColorPicker

func GetColorChangedListeners(view View, subviewID ...string) []func(ColorPicker, Color, Color)

Returns the ColorChangedListener list of an ColorPicker subview. If there are no listeners then the empty list is returned. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned.

func GetColorPickerValue(view View, subviewID ...string) Color

Returns the value of ColorPicker subview. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned.

func GetDataList(view View, subviewID ...string) []string

Returns the data list of an editor. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned.