|
IDL Reference Guide: IDL GUIBuilder Widget Reference |
|
In IDL, a button widget can be a button (push button), radio button, or checkbox.
A push button is activated by a single-click. Push buttons can be of any size. You can set the Menu attribute to yes for a button widget, and then it can contain a pull-down menu. When you do so, the Label is enclosed in a box to indicate that the button is a menu button.
Radio buttons have two states, set and unset, and they belong to a group that allows only one radio button selection for that group. The group is defined as all buttons contained in the same exclusive base widget. When a radio button in a base (in a group) is selected, any other button selection in that base is cleared. When you create a radio button in the IDL GUIBuilder, it is created in an exclusive base widget, and you can add only radio buttons to that base.
Checkboxes have two states, set and unset, and they are grouped in a non-exclusive base widget. The base widget allows for any number of checkboxes to be set at one time, and you can also use single checkboxes in your interface. When you create a checkbox in the IDL GUIBuilder, it is created in an non-exclusive widget base, and you can add only checkboxes to this base.
When programming in IDL, you create push buttons, radio buttons, and checkboxes using the WIDGET_BUTTON function. For more information, see WIDGET_BUTTON.
| Note The bases in which radio buttons and checkboxes are created have the Layout attribute set to column so when you add more widgets they are lined up appropriately. |
To create several radio buttons or checkboxes in a base widget:
When you drop a button in an exclusive or non-exclusive base, the added buttons line up in columns; by default, these exclusive and non-exclusive bases have their Layout attribute set to Column.
For button widgets, you can set common attributes and button-specific attributes. For a list of common attributes, see Common Attributes. The following is a list of button widget attributes, which apply to push buttons, radio buttons, and/or checkboxes:
The Alignment attribute specifies how the text label is aligned in the button widget. These are the possible alignment values:
In the generated *.pro file, this value is specified by the ALIGN_CENTER, the ALIGN_LEFT, or the ALIGN_RIGHT keyword to the widget creation routine.
The Bitmap attribute allows you to select a bitmap to be displayed in the push button, and it allows you to access the Bitmap Editor to create or modify a bitmap file (*.bmp file). This value applies only to buttons (not to radio buttons or checkboxes).
To set this value, set the Type value to Bitmap, then the Bitmap attribute displays in the Properties dialog. When the button type is "Bitmap", you can set the Bitmap attribute to the path and name of the bmp file.
When you click on the arrow in the Bitmap attribute Value field, you can choose from the following options:
In the generated *.pro file, this value is specified with the VALUE and Bitmap keyword to the widget creation routine.
For information on using the Bitmap Editor, see Using the Bitmap Editor.
The Label attribute specifies the text label for a button. If you set the Type attribute to Bitmap (for push buttons only), this value is not displayed. For radio buttons and checkboxes, the label value is the text string displayed next to the button. By default, this value is set to Button, and you can change it to any string.
In the generated *.pro file, this value is specified with the VALUE keyword to the widget creation routine.
The No Release attribute enables and disables the dispatching of button release events for radio buttons and checkboxes. Normal buttons do not generate events when released, but radio buttons and checkboxes can return separate events for the select and release actions.
These are the possible values:
In the generated *.pro file, this values is specified with the NO_RELEASE keyword to the widget creation routine.
| Note The No Release attribute is for radio buttons and checkboxes only. |
The Tab Mode attribute specifies what support the widget has for receiving or losing focus through tabbing. By default, this value is set to Inherit.
| Note For radio buttons, the tab mode is automatically inherited from the parent base and cannot be individually specified. |
| Note It is not possible to tab to disabled (Sensitive = False) or hidden (Visible = False) widgets. |
Allowable values are:
| Note The default tab mode of a widget is Inherit. The tabbing support defined for the parent base, described in Base Widget Attributes, is inherited by widget children unless otherwise specified. |
| 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. |
In the generated *.pro file, this value is specified with the TAB_MODE keyword to the widget creation routine. For more information on tabbing among widgets, see Tabbing in Widget Applications.
The Tooltip attribute specifies a short text string that will be displayed when the mouse cursor is positioned over the button. The length of the tooltip is not explicitly limited, but since tooltips are displayed in a single line, it is best to keep the text short.
The Type attribute specifies the type of push button.
| Note This attribute applies only to push buttons, not to radio buttons or checkboxes. |
The possible values are:
In the generated *.pro file, this value is specified with the MENU or VALUE keywords to the widget creation routine.
For button widgets, you can set common event properties and button-specific event properties. By default, event values are not set. For a list of events common to all widgets, see Common Events.
The following is the event property specific to button widgets; it applies to push buttons, radio buttons, and checkboxes:
The OnButtonPress value is the routine that is called when the button is pressed, or when a button is released for a radio button or checkbox button. In the generated *_eventcb.pro file, the event calling sequence looks like this:
pro <RoutineName>, Event
where RoutineName is the name of the event procedure you specify. Event is the returned event structure, which is of the following type:
{ WIDGET_BUTTON, ID:0L, TOP:0L, HANDLER:0L, SELECT:0 }
SELECT is set to 1 if the button was set, and 0 if released. Push buttons do not generate events when released, so SELECT will always be 1 for a push button. However, radio buttons and checkboxes are toggle buttons, and thus return separate events for the set and the release actions. To control whether or not release events are returned, set the No Release attribute.
IDL Online Help (March 06, 2007)