The CW_CLR_INDEX function creates a compound widget that displays a horizontal color bar and allows the user to select a color index. Clicking on the bar sets the color index.

This routine is written in the IDL language. Its source code can be found in the file in the lib subdirectory of the IDL distribution.


Result = CW_CLR_INDEX( Parent [, COLOR_VALUES=vector | [, NCOLORS=value] [, START_COLOR=value]] [, EVENT_FUNC=‘function_name’] [, /FRAME] [, LABEL=string] [, NCOLORS=value] [, START_COLOR=value] [, TAB_MODE=value] [, UNAME=string] [, UVALUE=value] [, VALUE=value] [, XSIZE=pixels] [, YSIZE=pixels] )

Return Value

This function returns the widget ID of the newly-created color index widget.



The widget ID of the parent widget.



A vector of color indices containing the colors to be displayed in the color bar. If omitted, NCOLORS and START_COLOR specify the range of color indices.


A string containing the name of a function to be called by the WIDGET_EVENT function when an event arrives from a widget in the widget hierarchy rooted at the newly-created widget. This function is called with the return value structure whenever a button is pressed, and follows the conventions for user-written event functions.


If set, a frame will be drawn around the widget.


A text label that appears to the left of the color bar.

Note: You can use language catalogs to internationalize this value with strings in particular languages.


The number of colors to place in the color bar. The default is !D.N_COLORS.


Set this keyword to the starting color index, placed at the left of the bar.


Set this keyword to one of the values shown in the table below to determine how the widget hierarchy can be navigated using the Tab key. The TAB_MODE setting is inherited by lower-level bases and child widgets unless it is explicitly set on an individual widget.

Note: It is not possible to tab to disabled (SENSITIVE=0) or hidden (MAP=0) widgets.

Valid settings are:




Disable navigation onto or off of the widget. This is the default. Child widgets automatically inherit the tab mode of the parent base as described in Inheriting the TAB_MODE Value.


Enable navigation onto and off of the widget.


Navigate only onto the widget.


Navigate only off of the widget.

Note: In widget applications on the UNIX platform, the Motif library controls what widgets are brought into and released from focus using tabbing. The TAB_MODE keyword value is always zero, and any attempt to change it is ignored when running a widget application on the UNIX platform. Tabbing behavior may vary significantly between UNIX platforms; do not rely on a particular behavior being duplicated on all UNIX systems.


Set this keyword to a string that can be used to identify the widget in your code. You can associate a name with each widget in a specific hierarchy, and then use that name to query the widget hierarchy and get the correct widget ID.

To query the widget hierarchy, use the WIDGET_INFO function with the FIND_BY_UNAME keyword. The UNAME should be unique to the widget hierarchy because the FIND_BY_UNAME keyword returns the ID of the first widget with the specified name.


The “user value” to be assigned to the widget.


Set this keyword to the index of the color that is to be initially selected. The default is the START_COLOR.


The width of the color bar in pixels. The default is 192.


The height of the color bar in pixels. The default is 12.


The widget ID returned by most compound widgets is actually the ID of the compound widget’s base widget. This means that many keywords to the WIDGET_CONTROL and WIDGET_INFO routines that affect or return information on base widgets can be used with compound widgets.

In addition, you can use the GET_VALUE and SET_VALUE keywords to WIDGET_CONTROL to obtain or set the value of the color selection widget. The value of a CW_CLR_INDEX widget is the index of the color selected.

See Writing Compound Widgets for a more complete discussion of controlling compound widgets using WIDGET_CONTROL and WIDGET_INFO.

Widget Events Returned by the CW_CLR_INDEX Widget

This widget generates event structures with the following definition:

Event = {CW_COLOR_INDEX, ID: base, TOP:, HANDLER: 0L, VALUE:c}

The VALUE field is the color index selected.

Version History

Pre 4.0



Added TAB_MODE keyword

See Also