Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

Listbox Widget Properties


The listbox displays a list of text items from which a user can select, by clicking on them. The listboxes have vertical scroll bars to allow viewing of a long list of items.

When programming in IDL, you create listbox widgets using the WIDGET_LIST function. For more information, see WIDGET_LIST.

Listbox Widget Attributes

For listbox widgets, you can set common attributes and listbox-specific attributes. For a list of common attributes, see Common Attributes. These are the listbox widget attributes:

Height

The Height attribute specifies the height of the listbox based on the number of lines that are visible. The possible values for the attribute are 1 to n. By default, Height is set to 1, which indicates the default size of one line will be used.

Note that the final size of the widget may be adjusted to include space for scroll bars, which are not always visible, so the listbox might be slightly larger than specified.

In the generated *.pro file, this value specified with the YSIZE keyword to the widget creation routine.

Initial Value

The Initial Value attribute specifies the initial list of values that are placed in the list widget. By default, the list is empty, but you can set this value to a scalar string or a list of strings. List widgets are sized based on the length (in characters) of the longest item specified in the array of values.

To enter more than one string in the Value field, type in a string, then press Control+Enter (at the end of each line). This moves you to the next line. When you have entered as many strings as you want, press Enter to set the values.

In the generated *.pro file, this value is specified by the VALUE keyword to the widget creation routine.

Multiple

The Multiple attribute determines if the user can select multiple list items. By default, the setting is False, which allows for only one selection. To enable multiple list item selection, set this value to True. Multiple selections are handled using the method appropriate to the platform the application is running on.

In the generated *.pro file, this value is specified with the MULTIPLE keyword to the widget creation routine.

Tab Mode

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
It is not possible to tab to disabled (Sensitive = False) or hidden (Visible = False) widgets.

Allowable values are:

Value
Description
Inherit
Upon creation, the widget inherits the tabbing support of the parent base.
None
Disallow tabbing into or out of the widget.
In and Out
Allow tabbing into and out of the widget.
In Only
Allow tabbing into the widget only.
Out Only
Allow tabbing off of the widget only.

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.

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.

Width

The Width attribute specifies the width of the listbox in characters. The possible values for the attribute are 0 to n. By default, Width is set to 0, which indicates that default sizing will be used, as long as the Component Sizing attribute is set to default.

By default, IDL sizes widgets to fit the situation. However, if the desired effect is not produced, use explicit Component Sizing with the Width attribute to set your own sizing. The final size of the widget may be adjusted to include space for the scroll bar, which is not always visible, so your widget may be slightly larger than specified.

In the generated *.pro file, this value specified with the XSIZE keyword to the widget creation routine.

Listbox Widget Events

For listbox widgets, you can set common event properties and listbox-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 listbox widgets:

OnContextEvent

The OnContextEvent value is the routine name that is called when the user clicks the right-hand mouse button over the list widget. 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 event structure returned when the user clicks the right-hand mouse button and is of the following type:

{WIDGET_CONTEXT, ID:0L, TOP:0L, HANDLER:0L, X:0L, Y:0L} 

The X and Y fields give the device coordinates at which the event occurred, measured from the upper left corner of the base widget.

OnSelectValue

The OnSelectValue specifies a valid IDL routine name that is called when a list item is selected. When a user clicks on an item in the listbox to select the item, an event is generated.

When you set this event value, the calling sequence looks like this in the generated *_eventcb.pro file:

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_LIST, ID:0L, TOP:0L, HANDLER:0L, INDEX:0L, CLICKS:0L } 

The first three fields are the standard fields found in every widget event. INDEX returns the index of the selected item. This index can be used to subscript the array of names originally used to set the widget's value. CLICKS returns either 1 or 2, depending on how the list item was selected. If the list item is double-clicked, CLICKS is set to 2.

Note
If you are writing a widget application that requires the user to double-click on a list widget, you will need to handle two events. The CLICKS field will return a 1 on the first click and a 2 on the second click.


Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]