Share

Colorpicker UI Control

A colorpicker control is used to place a 3ds Max color selection swatch on the rollout. The user can click the swatch to display a Color Selector dialog or drag colors to or from it.

The syntax is:

colorpicker <name> [ <caption> ] [color:<color>] [alpha:<boolean>] [fieldWidth:<number>] [height:<number>] [modal:<boolean>] [title:<string>] [toolTip:<string>] \
[colorContext:{#none | #sceneSurface | #sceneLight | #data | #sRGB | #ui}] \
[notifyAfterAccept:<boolean>]

The default alignment of colorpicker items is #left .

EXAMPLE:

   rollout change_wirecolor "Object Color Changer"
   (
     colorpicker theColor "Wireframe color:" color:[0,0,255] modal:false
     on theColor changed new_col do selection.wirecolor = new_col
   )
   createDialog change_wirecolor

In this example, the color picker is set to non-modal, which means that changing the color value will change the wireframe color of all selected objects instantly and interactively. Setting modal: to true would let the user adjust the color without feedback in the viewports and assign the result using the OK button.

Parameters:

color:

Initial color of the swatch. Defaults to blue.

title:

The title displayed on the Color Selector dialog. Defaults to "Choose a color".

fieldWidth:

The width in pixels of the swatch. Defaults to 40.

height:

The height in pixels of the swatch. Defaults to 16.

modal:

By default, the color picker is declared as modal which prevents key strokes from being passed to 3ds Max. When the keyword argument modal: is set to false , the color picker will enable the shortcuts.

alpha:

When set to true , clicking the color swatch brings up the color picker with alpha support. Defaults to false . If the color swatch is tied to an #acolor of #point4 parameter, this parameter is automatically set to true . Available in 3ds Max 6 and higher.

toolTip:

Provides text for a tooltip for the colorpicker; no tooltip if unsupplied. Available in in 3ds Max 2017 and higher.

colorContext

The default colorContext value is #none. The colorContext specifies the color context of the color picker. The meaning of the options are:

#none - The context of this color/texture is unspecified.

#sceneSurface - The context of this color/texture is to be used in the scene defining the color of a surface. The rules of energy conservation will be applied, that will effectively limit the linear RGB values to be in the range of 0.0 to 1.0.

#sceneLight - The context of this color/texture is to be used in the scene defining the color of a light. No energy conservation rules will be applied, any given values for RGB may be valid.

#data - The context of this color/texture is to be used as pure data, for things like normals, absorption coefficients, etc.

#sRGB, #ui - The context of this color/texture is to be used in the UI - defined in sRGB (IEC 61966-2-1). There is no additional conversion happening besides the implicit sRGB to monitor ICM conversion of the operating system.

Example:

rollout test "test"
(
    colorpicker cp1 "cp1" notifyAfterAccept:true title:"colorContext #none"
    colorpicker cp2 "cp2" title:"colorContext #none"
    colorpicker cp3 "cp3" colorContext:#sceneSurface title:"colorContext #sceneSurface" 
    colorpicker cp4 "cp4" colorContext:#sceneLight  title:"colorContext #sceneLight"
    colorpicker cp5 "cp5" colorContext:#data  title:"colorContext #data"
    colorpicker cp6 "cp6" colorContext:#ui title:"colorContext #ui"
    on cp1 changed val do format "cp1 changed value: %\n" val
    on cp2 changed val do format "cp2 changed value: %\n" val
    on cp3 changed val do format "cp3 changed value: %\n" val
    on cp4 changed val do format "cp4 changed value: %\n" val
    on cp5 changed val do format "cp5 changed value: %\n" val
    on cp6 changed val do format "cp6 changed value: %\n" val
)
createdialog test 
test.cp1.color = orange 
test.cp2.color = orange 
test.cp3.color = orange 
test.cp4.color = orange 
test.cp5.color = orange 
test.cp6.color = orange 

Note that changing the color via script does not call the handler in either case.

Note the visual difference of the 6 color pickers. For the first 4 have color correction applied to the color.

Note that if opening the color selector, the different clamping of the float spinners for different colorContexts.

notifyAfterAccept:<bool>

If specified as true, the changed handler will only be called once when the color picker is closed, and only if the user clicks OK instead of Cancel. If not specified or specifed as false, the changed handler will be called as the user makes changes interactively in the color picker.

Properties

<colorpicker>.color Color

The current swatch color.

<colorpicker>.alpha Boolean

When set to true , clicking the color swatch brings up the color picker with alpha support.(Previously available in 3ds Max 6 as construction parameter only).

Events

on <colorpicker> changed <arg> do <expr>

Called when the user selects a new color in the open Color Selector dialog for this swatch or drops a new color on it. The <arg> argument contains the newcolor.

Was this information helpful?