iwidgets::combobox(1) | [incr Widgets] | iwidgets::combobox(1) |
iwidgets::combobox - Create and manipulate combination box widgets
iwidgets::combobox pathName ?options?
itk::Widget <- iwidgets::LabeledWidget <- iwidgets::Entryfield <- iwidgets::Combobox
background borderWidth cursor justify exportSelection foreground highlightColor highlightThickness insertWidth insertBackground insertOffTime insertOnTime insertWidth insertBorderWidth relief selectForeground selectBackground selectBorderWidth textVariable width
See the "options" manual entry for details on the standard options.
hscrollmode textBackground textFont vscrollmode
See the "scrolledlistbox" manual entry for details on the above inherited options.
show
See the "entry" manual entry for details on the above inherited option.
childSitePos command fixed focusCommand invalid textBackground textFont validate
See the "entryfield" class manual entry for details on the inherited options.
labelBitmap labelFont labelImage labelMargin labelPos labelText labelVariable sticky
See the "labeledwidget" class manual entry for details on the inherited options.
Name: arrowRelief Class: Relief Command-Line Switch: -arrowrelief
Name: completion Class: Completion Command-Line Switch: -completion
Name: dropdown Class: Dropdown Command-Line Switch: -dropdown
Name: editable Class: Editable Command-Line Switch: -editable
Name: grab Class: Grab Command-Line Switch: -grab
Name: listHeight Class: Height Command-Line Switch: -listheight
Name: margin Class: Margin Command-Line Switch: -margin
Name: popupCursor Class: Cursor Command-Line Switch: -popupcursor
Name: selectionCommand Class: SelectionCommand Command-Line Switch: -selectioncommand
Name: state Class: State Command-Line Switch: -state
Name: unique Class: Unique Command-Line Switch: -unique
The iwidgets::combobox command creates an enhanced entry field widget with an optional associated label and a scrollable list. When an item is selected in the list area of a Combobox, its value is then displayed in the entry field text area. Functionally similar to an Optionmenu, the Combobox adds (optional) list scrolling and (optional) item editing and inserting capabilities.
There are two basic styles of Comboboxes (determined by the -dropdown option): dropdown and simple. The dropdown style adds an arrow button to the right of the entry field which when activated will pop up (and down) the scrolled listbox beneath the entry field. The simple (non-dropdown) Combobox permanently displays the listbox beneath the entry field and has no arrow button. Either style allows an optional entry field label.
The iwidgets::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 ...?
Option and the args determine the exact behavior of the command. The following commands are possible for Combobox widgets:
icursor scan
See the "entry" manual entries for details on the above associated methods.
curselection index see size xview yview
See the "listbox" manual entries for details on the above associated methods.
getcurselection justify sort
See the "scrolledlistbox" manual entries for details on the above associated methods.
Name: entry Class: Entry
Name: list Class: Scrolledlistbox
The Combobox generally has the same bindings as its primary component items - the Scrolledlistbox and Entryfield. However it also adds these:
[1] Button-1 mouse press on the arrow key of a dropdown Combobox causes the list to be popped up. If the combobox is non-editable, a Button-1 press on the entry field area will also pop up the list.
[2] Button-1 mouse press anywhere on the display removes a dropdown listbox which has been popped up, unless the keypress is upon one of the Combobox scrollbars which scrolls the list. If it is pressed upon an item in the list area, that item will be selected before the list is removed.
[3] Button-3 mouse press on the arrow key of a dropdown Combobox causes the next item to be selected. Shift-Button-3 causes the previous item to be selected.
[4] Escape keypress removes a dropdown list which has been popped up.
[5] The <space> and <Return> keystrokes select the current item. They also remove the popped up list for dropdown comboboxes.
[6] Up and Down arrow keypresses from the entry field and arrow button component cause the previous and next items in the listbox to be selected respectively. Ctl-P and Ctl-N are similarly mapped for emacs emulation.
[7] Entry field and arrow button component Shift-Up and Shift-Down arrow keys pop up and down the listbox of a dropdown Combobox. The arrow button component also maps <Return> and <space> similarly.
package require Iwidgets 4.0
proc selectCmd {} {
puts stdout "[.cb2 getcurselection]"
}
#
# Non-editable Dropdown Combobox
#
iwidgets::combobox .cb1 -labeltext Month: \
-selectioncommand {puts "selected: [.cb1 getcurselection]"} \
-editable false -listheight 185 -popupcursor hand1
.cb1 insert list end Jan Feb Mar Apr May June Jul Aug Sept Oct Nov Dec
#
# Editable Dropdown Combobox
#
iwidgets::combobox .cb2 -labeltext "Operating System:" -selectioncommand selectCmd
.cb2 insert list end Linux HP-UX SunOS Solaris Irix
.cb2 insert entry end L
pack .cb1 -padx 10 -pady 10 -fill x
pack .cb2 -padx 10 -pady 10 -fill x
John S. Sigler
Mitch Gorman (logain@erols.com)
combobox, entryfield, scrolledlistbox, itk::Widget, entry, listbox, widget, iwidgets
Tk |