combobox - Combobox Megawidget
SYNOPSIS
|
See the options manual entry for detailed descriptions of the above options.
A combobox is a widget that displays a one-line text string, and
allows that string to be edited or selected from a dropdown list. When
first created a combobox's value is the null string unless a variable
is associated with the widget using the -textvariable option, in
which case it will be the value stored in the associated variable.
The combobox entry wiget is capable of displaying strings that are too
long to fit entirely within the widget's window. In this case only a
portion of the string will be displayed; commands described below may
be used to change the view in the window. Comboboxes use the standard
-xscrollcommand mechanism for interacting with scrollbars (see
the description of the -xscrollcommand option for
details). They also support scanning, as described below.
WIDGET-SPECIFIC OPTIONS
Database Name: buttonBackground
Database Class: ButtonBackground
Database Name: command
Database Class: Command
It is important to note that if the combobox has an associated
-textvariable, the command will not be called if the value of
the variable is changed external to the combobox.
Database Name: commandState
Database Class: State
Database Name: disabledBackground
Database Class: DisabledBackground
Database Name: disabledForeground
Database Class: DisabledForeground
Database Name: dropdownWidth
Database Class: DropdownWidth
Database Name: editable
Database Class: Editable
Database Name: elementBorderWidth
Database Class: BorderWidth
Database Name: height
Database Class: Height
Database Name: image
Database Class: Image
Database Name: listVariable
Database Class: ListVariable
Database Name: maxHeight
Database Class: Height
Database Name: openCommand
Database Class: Command
Database Name: value
Database Class: Value
Database Name: width
Database Class: Width
OVERVIEW
The combobox command creates a new window (given by the
pathName argument) and makes it into a dropdown combobox
widget. Additional options, described above, may be specified on the
command line. Currently no option database support is provided. The
combobox command returns its pathName arguument. At
the time this command is invoked, there must not exists a window named
pathName, but pathName's parent must exist.
WIDGET COMMAND
The combobox command creates a new Tcl command whose name is
pathName. This command may be used to invoke various operations on
the widget. It has the following general form:
pathName option ?arg arg ...? |
Many of the widget commands take one or more indicies as arguments. For list commands the indicies may take one of the forms acceptable to the standard listbox command. For all other commands the indicies may take the form of an indicie for a standard entry widget. See the appropriate man pages for more information.
The following commands are possible for combobox widgets:
Double-clicking mouse button 1 over the entry widget will display the dropdown list if it is not displayed, and hide it if it is. The value of the combobox won't change.
If -editable is set to false, single-clicking mouse button 1 over the entry widget will display the dropdown list if it is not displayed, and hide it if it is. The value of the combobox won't change.
Pressing the Up, Down, Next and Prior buttons (up arrow, down arrow, page up and page down, respectively) will display the dropdown list if it is not displayed. If it is displayed, these buttons will change the current selection on the list.
If -editable is true, pressing the Return or Tab key will set the value to the string in the entry widget. If the list is displayed and an item is selected, Return will set the value of the combobox to the selected item.
If -editable is false, pressing the Return key when the list is displayed will result in the value of the combobox changing to the currently highlighted item in the list. The list will be closed.
Pressing the escape key when the list is displayed will result in the list being closed with the value of the combobox remaining unchanged.
Clicking the mouse button over an element in the dropdown list will cause the clicked-on item to be the new value of the combobox, and the list will be closed.
If the combobox is disabled using the -state option, then the entry
widget's view can still be adjusted and text in the entry can be
selected, but no insertion cursor will be displayed, no text
modification will be possible, and the list cannot be displayed.
It has been reported that with some virtual window managers, switching
to a new virtual window while the dropdown list is visible will result
in the dropdown list appearing by itself in the new virtual window.
So the lesson here is: don't dork with your windows while the dropdown
list is visible. That, or get a better window manager.
BUGS
With some window managers it may be possible to move the window that
contains the combobox while the dropdown list is visible. In such a
case the dropdown list will stay where it originally appeared. Well
behaved window managers shouldn't let you move the window while the
list is displayed.