The CW_FIELD function creates a widget data entry field. The field consists of a label and a text widget. CW_FIELD can create string, integer, or floating-point fields. The default is an editable string field.
The returned value of this function is the widget ID of the newly-created field widget.
This routine is written in the IDL language. Its source code can be found in the file
cw_field.pro
in the
lib
subdirectory of the IDL distribution.
Like RETURN_EVENTS but return an event whenever the contents of a text field have changed.
Set this keyword to center the label above the text field. The default is to position the label to the left of the text field.
Set this keyword to have the field accept only floating-point values. Any number or string entered is converted to its floating-point equivalent.
A string containing the name of the font to use for the TITLE of the field. The font specified is a "device font" (an X Windows font on Motif systems; a TrueType or PostScript font on Windows or Macintosh systems). See for details on specifying names for device fonts. If this keyword is omitted, the default font is used.
The width, in pixels, of a frame to be drawn around the entire field cluster. The default is no frame.
Set this keyword to have the field accept only integer values. Any number or string entered is converted to its integer equivalent (using FIX). For example, if 12.5 is entered in this type of field, it is converted to 12.
Set this keyword to have the field accept only long integer values. Any number or string entered is converted to its long integer equivalent (using LONG).
Normally, the value in the text field can be edited. Set this keyword to make the field non-editable.
Set this keyword to make CW_FIELD return an event when a carriage return is pressed in a text field. The default is not to return events. Note that the value of the text field is always returned when the command
Set this keyword to have the field accept only string values. Numbers entered in the field are converted to their string equivalents. This is the default.
A string containing the text to be used as the label for the field. The default is "Input Field".
The initial value in the text widget. This value is automatically converted to the type set by the STRING, INTEGER, and FLOATING keywords described below.
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 field. If one of the FLOATING, INTEGER, LONG, or STRING keywords to CW_FIELD is set, values set with the SET_VALUE keyword to WIDGET_CONTROL will be forced to the appropriate type. Values returned by the GET_VALUE keyword to WIDGET_CONTROL will be of the type specified when the field widget is created. Note that if the field contains string information, returned values will be contained in a string array even if the field contains only a single string.
See Compound Widgets for a more complete discussion of controlling compound widgets using WIDGET_CONTROL and WIDGET_INFO .
This widget generates event structures with the following definition:
event = { ID:0L, TOP:0L, HANDLER: 0L, VALUE:'', TYPE:0 , UPDATE:0}
The VALUE field is the value of the field. TYPE specifies the type of data contained in the field and can be any of the following: 0=string, 1=floating-point, 2=integer, 3=long integer (the value of TYPE is determined by setting one of the STRING, FLOAT, INTETER, or LONG keywords). UPDATE contains a zero if the field has not been altered or a one if it has.
The code below creates a main base with a field cluster attached to it. The cluster accepts string input, has the title "Name", and has a frame around it: