<!-- Generated from combobox.man by tcllib/doctools/mpexpand with fmt.tmml -->
<manpage id='combobox' cat='cmd' title='combobox' version='2.3' package='combobox'>
<namesection>
<name>combobox</name>
<desc>Combobox Megawidget</desc>

</namesection>






<synopsis>
<syntax>
package require combobox 2.3 
combobox::combobox <m>pathName</m> <o>options</o> 
</syntax>
</synopsis>
<section>
<title>DESCRIPTION</title>

This package provides a new widget named "combobox" which combines an
entry widget and a dropdown menu into a single widget.

</section>
<section id='standardoptions'>
<title>STANDARD OPTIONS</title>

-background
-borderwidth
-cursor
-font
-foreground
-height
-highlightthickness
-highlightbackground
-highlightcolor
-maxheight
-relief
-selectbackground
-selectborderwidth
-selectforeground
-state
-textvariable
-xscrollcommand


<p>

See the options manual entry for detailed descriptions of the above options.

</p>
</section>
<section id='widgetspecificoptions'>
<title>WIDGET-SPECIFIC OPTIONS</title>


<optionlist>


<optiondef>
<name>-buttonbackground</name>
<dbname>buttonBackground</dbname>
<dbclass>ButtonBackground</dbclass>
<desc>

Defines the background color of the button used to activate the
dropdown list.

</desc>
</optiondef>
<optiondef>
<name>-command</name>
<dbname>command</dbname>
<dbclass>Command</dbclass>
<desc>

Defines a command to be run whenver the user selects a value from the
dropdown list box. If the combobox is editable, the command will also 
be called whenever the user presses return or the widget loses the keyboard
focus and the value has changed. The command will have two values 
appended to it: the name of the window and the new value of the
combobox. The value is considered to have changed if it differs from
the value when the entry first gained focus, or since the last time
the command was called.  
<br/>
It is important to note that if the combobox has an associated
<m>-textvariable</m>, the command will not be called if the value of
the variable is changed external to the combobox. 

</desc>
</optiondef>
<optiondef>
<name>-commandstate</name>
<dbname>commandState</dbname>
<dbclass>State</dbclass>
<desc>

One of "normal" or "disabled". If set to "disabled", the value of 
the B&lt;-command&gt; option will not be evaluated when the value of the
combobox changes. 

</desc>
</optiondef>
<optiondef>
<name>-disabledbackground</name>
<dbname>disabledBackground</dbname>
<dbclass>DisabledBackground</dbclass>
<desc>

Defines the background color for the combobox when it is disabled.

</desc>
</optiondef>
<optiondef>
<name>-disabledforeground</name>
<dbname>disabledForeground</dbname>
<dbclass>DisabledForeground</dbclass>
<desc>

Defines the foreground color for the combobox when it is disabled.

</desc>
</optiondef>
<optiondef>
<name>-dropdownwidth</name>
<dbname>dropdownWidth</dbname>
<dbclass>DropdownWidth</dbclass>
<desc>

Defines the width of the dropdown list. If null or 0, the dropdown
listbox width will be the same as the always-visible portion of the 
combobox (ie: the entry and menubutton). Otherwise the value specifies
the number of average-sized characters to display in the dropdown listbox.

</desc>
</optiondef>
<optiondef>
<name>-editable</name>
<dbname>editable</dbname>
<dbclass>Editable</dbclass>
<desc>. 

A boolean value which specifies whether the entry widget of the
combobox can be typed in. If false, values may only be set by
selecting them from the dropdown list.

</desc>
</optiondef>
<optiondef>
<name>-elementborderwidth</name>
<dbname>elementBorderWidth</dbname>
<dbclass>BorderWidth</dbclass>
<desc>

Specifies the width of borders drawn around the internal elements of
the widget (the button and the scrollbars for the dropdown list).

</desc>
</optiondef>
<optiondef>
<name>-height</name>
<dbname>height</dbname>
<dbclass>Height</dbclass>
<desc>

Specifies the hight of the dropdown list, in number of lines. A value
of zero will make the dropdown list just tall enough to hold all of
the elements in the list. The height defaults to 10.

</desc>
</optiondef>
<optiondef>
<name>-image</name>
<dbname>image</dbname>
<dbclass>Image</dbclass>
<desc>

Defines an image to use on the button used to drop down the list. If
it is not specified it defaults to a small black triangle.

</desc>
</optiondef>
<optiondef>
<name>-listvar</name>
<dbname>listVariable</dbname>
<dbclass>ListVariable</dbclass>
<desc> 

Specifies the name of a variable associated with the dropdown listbox.
If the variable changes the listbox will automatically update itself
to reflect the new value. Attempts to unset a variable in use as a
listvar will fail but will not generate an error.

</desc>
</optiondef>
<optiondef>
<name>-maxheight</name>
<dbname>maxHeight</dbname>
<dbclass>Height</dbclass>
<desc>

Sets the maximum height of the dropdown list, in the event
B&lt;-height&gt; is set to zero and there are a large number of items in the
list. If this value is set to 0 (zero) the list will be as large as
the total number of items in the list. The maxheight defaults to 10.

</desc>
</optiondef>
<optiondef>
<name>-opencommand</name>
<dbname>openCommand</dbname>
<dbclass>Command</dbclass>
<desc>

If this option is specified then it provides a Tcl command to
execute each time the combobox is opened (eg: when the dropdown
listbox is displayed). The command is invoked by the B&lt;open&gt; widget
command before opening the combobox. 

</desc>
</optiondef>
<optiondef>
<name>-value</name>
<dbname>value</dbname>
<dbclass>Value</dbclass>
<desc>

Specifies the value for the combobox.

</desc>
</optiondef>
<optiondef>
<name>-width</name>
<dbname>width</dbname>
<dbclass>Width</dbclass>
<desc>

Specifies an integer value indicating the desired width of the
combobox entry widget, in average size characters of the widget's
font. If the value is less than or equal to zero, the widget picks a
size large enough to hold its current text.

</desc>
</optiondef>

</optionlist>

</section>
<section id='overview'>
<title>OVERVIEW</title>

The <cmd>combobox</cmd> command creates a new window (given by the 
<m>pathName</m> 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
<cmd>combobox</cmd> command returns its <emph>pathName</emph> arguument. At
the time this command is invoked, there must not exists a window named
<emph>pathName</emph>, but <emph>pathName's</emph> parent must exist.


<p>

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 <m>-textvariable</m> option, in
which case it will be the value stored in the associated variable.

</p>
<p>

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.

</p>
</section>
<section id='widgetcommand'>
<title>WIDGET COMMAND</title>

The <cmd>combobox</cmd> command creates a new Tcl command whose name is
<m>pathName</m>. This command may be used to invoke various operations on
the widget. It has the following general form:


<example>
    <m>pathName</m> option <o>arg arg ...</o>

</example>

<emph>option</emph> and the <emph>arg</emph>s determine the exact behavior of the command.


<p>

Many of the widget commands take one or more indicies as
arguments. For <emph>list</emph> 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.

</p>
<p>

The following commands are possible for combobox widgets:

</p>
<p>

</p>
<dl>


<dle>
<dt><m>pathName</m> <emph>bbox</emph> <emph>index</emph></dt>
<dd>

Returns a list of four numbers describing the bounding box of the
characters given by <emph>index</emph>. The first two elements of the list give
the x and y coordinates of the upper-left corner of the screen area
covered by the character (in pixels relative to the widget) and the
last two elements give the width and height of the character, in
pixels. The bounding box may refer to a region outside the visible
area of the window.  

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>cget</emph> <emph>option</emph></dt>
<dd>

Returns the current value for the configuration option give 
by <emph>option</emph>. <emph>Option</emph> may have any of the values accepted by 
the <cmd>combobox</cmd> command.

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>close</emph></dt>
<dd>

Causes the dropdown listbox of the widget to be withdrawn if it is
currently displayed.  
 
</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>configure</emph> <emph>option</emph></dt>
<dd>

Query or modify the configuration options of the widget. If no option
is specified, returns a list describing all of the available options
for pathName, though not in the same format as describe in
Tk_ConfigureInfo. The format will be a list, where each element will
be a list of two values: an option name and the current value.

<br/>

If <emph>option</emph> is specified with no value, then the command
returns a list describing the one named <emph>option</emph>. This list will be
identical to the corresponding sublist of the value returned if no
<emph>option</emph> is specified.  If one or more option-value pairs are
specified, then the command modifies the given widget <emph>option</emph>(s) to
have the given value(s);  in this case the command returns an empty
string. <emph>Option</emph> may have any of the values accepted by the entry
command. 

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>curselection</emph></dt>
<dd>

Returns the index of the dropdown list item that matches the value
of the combobox, or -1 if the combobox is editable and the string
doesn't match a value in the list.  

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>delete</emph> <emph>first</emph> <o>last</o></dt>
<dd>

Delete one or more elements from the combobox entry widget. <emph>First</emph>
is the index of the first character to delete, and <emph>last</emph> is the index
of the character just after the last one to delete. If <emph>last</emph> isn't
specified it defaults to <emph>first</emph>+1, i.e. a single character is
deleted. This command returns an empty string.  

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>get</emph></dt>
<dd>

Returns the combobox's string.

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>icursor</emph> <emph>index</emph></dt>
<dd>

Arrange for the insertion cursor to be displayed just before the
character given by <emph>index</emph>. Returns an empty string.

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>index</emph> <emph>index</emph></dt>
<dd>

Returns the numerical index corresponding to <emph>index</emph>

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>insert</emph> <emph>index</emph> <emph>string</emph></dt>
<dd>

Insert the characters of <emph>string</emph> just before the character indicated
by <emph>index</emph>. Returns an empty string.

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>list</emph> <emph>option</emph> <emph>args</emph></dt>
<dd>

This command is used to manipulate the items in the dropdown
list. It has several forms, depending on <emph>option</emph>:


<dl>


<dle>
<dt><emph>list</emph> <emph>delete</emph> <emph>first</emph> <o>last</o></dt>
<dd>

Deletes one or more elements of the dropdown list.  First and last are
indices specifying the first and last elements in the range to delete.
If last isn't specified it defaults to first, i.e. a single element is
deleted.  

</dd>
</dle>
<dle>
<dt><emph>list</emph>  <emph>get</emph> <emph>first</emph> <o>last</o></dt>
<dd>

If last is omitted, returns the contents of the dropdown list element
indicated by first, or an empty string if first refers to a
non-existent element. If last is specified, the command returns a list
whose elements are all of the dropdown list elements between first and last,
inclusive. Both first and last may have any of the standard forms for
indices. 

</dd>
</dle>
<dle>
<dt><emph>list</emph> <emph>index</emph> <emph>index</emph></dt>
<dd>

Returns the integer index value that corresponds to index. If index is
end the return value is a count of the number of elements in the
dropdown list (not the index of the last element). 

</dd>
</dle>
<dle>
<dt><emph>list</emph> <emph>insert</emph> <emph>index</emph>  <o>element element ...</o></dt>
<dd>

Inserts zero or more new elements in the list just before the element
given by index.  If index is specified as end then the new elements
are added to the end of the list.  Returns an empty string.  

</dd>
</dle>
<dle>
<dt><emph>list</emph> <emph>size</emph></dt>
<dd>

Returns a decimal string indicating the total number of elements in
the dropdown list.  <br/>

</dd>
</dle>

</dl>

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>open</emph></dt>
<dd>

Causes the dropdown listbox of the combobox to be displayed if it 
is currently hidden.

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>scan</emph> <emph>option</emph> <emph>args</emph></dt>
<dd>

This command is used to implement scanning on the combobox entry
widget.  It has two forms, depending on option:  


<dl>


<dle>
<dt><m>pathName</m> <emph>scan mark</emph> <emph>x</emph></dt>
<dd>

Records x and the current view in the entry window;  used in
conjunction with later <emph>scan dragto</emph> commands.  Typically this
command is associated with a mouse button press in the widget.  It
returns an empty string.  

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>scan dragto</emph> <emph>x</emph></dt>
<dd>

This command computes the difference between its <emph>x</emph> argument 
and the <emph>x</emph> argument to the last <emph>scan mark</emph>  command 
for the widget.  It then adjusts the view left or right by 10 times 
the difference in x-coordinates.  This command is typically associated
with mouse motion events in the widget, to produce the effect of 
dragging the entry at high speed through the window.  The return 
value is an empty string.   <br/>

</dd>
</dle>

</dl>

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>select</emph> <emph>index</emph></dt>
<dd>

Selects the item in the dropdown list represented by <emph>index</emph> and
makes that the current value of the combobox.

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>selection</emph> <emph>option</emph> <emph>arg</emph></dt>
<dd>

This command is used to adjus the selection within the editable
portion of the combobox. It has several forms, depending on 
<emph>option</emph>:


<dl>


<dle>
<dt><m>pathName</m> <emph>selection</emph> <emph>adjust</emph> <m>index</m></dt>
<dd>

Locate the end of the selection nearest to the character given by
<m>idnex</m> (i.e. including but not going beyond <m>index</m>). The
other end of the selection is made the anchor point for future
<emph>select to</emph> commands. If the selection isn't currently in
the editable portion of the combobox, then a new selection is created
to include the characters between <m>index</m> and the most recent
selection anchor point, inclusive. Returns an empty string.

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>selection</emph> <emph>clear</emph></dt>
<dd>

Clear the selection if it is currently in this widget. If the
selection isn't in this widget then the command has no
effect. Returns an empty string.

</dd>
</dle>
<dle>
<dt><m>pathname</m> <emph>selection</emph> <emph>from</emph> <m>index</m></dt>
<dd>

Set the selection anchor point to just before the character given by
<m>index</m>. Doesn't change the selection. Returns an empty string.

</dd>
</dle>
<dle>
<dt><m>pathname</m> <emph>selection</emph> <emph>parent</emph></dt>
<dd>

Returns 1 if there are characters selected in the editable portion of
the combobox, otherwise it returns 0.

</dd>
</dle>
<dle>
<dt><m>pathname</m> <emph>selection</emph> <emph>range</emph> <m>start</m> <m>end</m></dt>
<dd>

Sets the selection to include the characters starting with the one
indexed by <m>start</m> and ending with the one just before <m>end</m>. 
If <m>end</m> refers to the same character as <m>start</m> or an
earlier one, then the selection is cleared.

</dd>
</dle>
<dle>
<dt><m>pathname</m> <emph>selection</emph> <emph>to</emph> <m>index</m></dt>
<dd>

If <m>index</m> is before the anchor point, set the selection to the
characters from <m>index</m> up to but not including the anchor
point. If <m>index</m> is the same as the anchor point, do nothing. If 
<m>index</m> is after the anchor point, set the selection to the
characters from the anchor point up to but not including <m>index</m>. 
The anchor point is determined by the most recent <emph>select from</emph> 
or <emph>select adjust</emph> command in this widget. If the selection
isn't in this widget then a new selection is created using the most
recent anchor point specified for the widget. Returns an empty string.
<br/>

</dd>
</dle>

</dl>

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>subwidget</emph> <o>name</o></dt>
<dd>

This command returns a list of internal widget names if given no
arguments, or returns the internal widget path for the widget identified
by <emph>name</emph>. 

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>xview</emph> <emph>args</emph></dt>
<dd>

This command is used to query and change the horizontal position of
the text in the widget's window.  It can take any of the following
forms:


<dl>


<dle>
<dt><m>pathName</m> <emph>xview</emph></dt>
<dd>

Returns a list containing two elements. Each element is a real
fraction between 0 and 1;  together they describe the horizontal span
that is visible in the window. For example, if the first element is .2
and the second element is .6, 20% of the entry's text is off-screen to
the left, the middle 40% is visible in the window, and 40% of the text
is off-screen to the right. These are the same values passed to
scrollbars via the <m>-xscrollcommand</m> option. 

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>xview</emph> <emph>index</emph></dt>
<dd>

Adjusts the view in the window so that the character given by <emph>index</emph> is
displayed at the left edge of the window.

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>xview</emph> <emph>moveto</emph> <emph>fraction</emph></dt>
<dd>

Adjusts the view in the window so that the character <emph>fraction</emph> of the
way through the text appears at the left edge of the window. <emph>Fraction</emph>
must be a fraction between 0 and 1.

</dd>
</dle>
<dle>
<dt><m>pathName</m> <emph>xview</emph> <emph>scroll</emph> <emph>number</emph></dt>
<dd>
<emph>what</emph>

This command shifts the view in the window left or right according to
<emph>number</emph> and <emph>what</emph>. <emph>Number</emph> must be an integer. 
<emph>What</emph> must be
either units or pages or an abbreviation of one of these. If <emph>what</emph>
is units, the view adjusts left or right by number average-width
characters on the display;  if it is pages then the view adjusts by
number screenfuls. If <emph>number</emph> is negative then characters farther to
the left become visible;  if it is positive then characters farther to
the right become visible.   

</dd>
</dle>

</dl>

</dd>
</dle>

</dl>

</section>
<section id='defaultbindings'>
<title> DEFAULT BINDINGS</title>

Bindings in the entry widget of the combobox are the same as for
normal entry widgets, with the following exceptions:


<p>

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.

</p>
<p>

If <m>-editable</m> 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.

</p>
<p>

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.

</p>
<p>

If <m>-editable</m> 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.

</p>
<p>

If <m>-editable</m> 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.

</p>
<p>

Pressing the escape key when the list is displayed will result in the
list being closed with the value of the combobox remaining unchanged.

</p>
<p>

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.

</p>
<p>

If the combobox is disabled using the <m>-state</m> 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.

</p>
</section>
<section id='bugs'>
<title>BUGS</title>

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.


<p>

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. 

</p>
<p>

So the lesson here is: don't dork with your windows while the dropdown
list is visible. That, or get a better window manager. 

</p>
</section>



</manpage>
