JavaScript EditorFree JavaScript Editor     Perl Manuals 

Main Page

7.5. Listbox Style

The default -relief of a Listbox is 'sunken'. The default -borderwidth is 2. Figure 7-3 shows the five different relief types (flat, raised, ridge, groove, and sunken). In the first window, the default -borderwidth is used; in the second window, a -borderwidth of 4 is used. To save space in the windows, we didn't draw any Scrollbars.

Figure 7-3

Figure 7-3. Examples of -relief and -borderwidth in Listboxes

7.5.1. Style of Selected Items

There is also a border width associated with any selected text. This is controlled by the -selectborderwidth option. Figure 7-4 shows what changing the selection border width to 4 does to the Listbox.

Figure 7-4

Figure 7-4. Example of -selectborderwidth => 4

Listbox Indexes

The items in a Listbox widget are ordered. The first Listbox item is at index 0, and the numbers increment by 1. These values are valid for any of the methods that require index values. They are as follows:

An integer index. The first item in a Listbox is at index 0.

The index within the Listbox that has the location cursor. If the Listbox has the keyboard focus, it will be displayed with an underline.

This index is set with the selectionAnchor(...) method.

The end of the Listbox. Depending on which method is using this index, it could mean just after the last element (such as when insert is used), or it could mean the last element in the Listbox (such as when delete is used).

The Listbox item that covers the point at the coordinate (x, y) (pixel coordinates). The closest item will be used if (x, y) is not at a specific item.

7.5.2. Special Listbox Resizing

The -setgrid option changes how the window is drawn when it's resized. Using -setgrid => 1 causes the window to stay resized to the grid created by the Listbox widget. Essentially, this means that the Listbox will display only complete lines (no half lines) and complete characters. A side benefit is that the Listbox will always display at least one line and will remain in sight when the visible window is resized. This option has nothing to do with which geometry manager you use to put the Listbox in the window.

JavaScript EditorJavaScript Formatter     Perl Manuals