HyperWorks Tools

hwtk::combobox

hwtk::combobox

Previous topic Next topic No expanding text in this topic  

hwtk::combobox

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

NAME

hwtk::combobox - Text field with popdown selection list.

 

DESCRIPTION

A hwtk::combobox combines a text field with a pop-down list of values; the user may select the value of the text field from among the values in the list.

 

SYNOPSIS

hwtk::combobox - pathName ?option value? ...

 

 

STANDARD OPTIONS

-clientdata, clientData, ClientData

-height, height, Height

-help, help, Text

-helpcommand, helpcommand, Command

-state, state, State

-textvariable, textVariable, Variable

-width, width, Width

 

WIDGET-SPECIFIC OPTIONS

Command-Line Name: -invalidcommand

Database Name: invalidCommand

Database Class: InvalidCommand

A script template to evaluate whenever the validateCommand returns 0. See Validation Options for more information.

 

 

Command-Line Name: -justify

Database Name: justify

Database Class: Justify

Specifies how the text is aligned within the widget. One of left, center, or right.

 

Command-Line Name: -postcommand

Database Name: postCommand

Database Class: PostCommand

A Tcl script to evaluate immediately before displaying the listbox. The -postcommand script may specify the -values to display.

 

 

Command-Line Name: -selcommand

Database Name: selcommand

Database Class: Command

A Tcl script to evaluate immediately after selecting from the dropdown listbox.

 

 

Command-Line Name: -validate

Database Name: validate

Database Class: Validate

Specifies the mode in which validation should operate: none, focus, focusin, focusout, key, or all. Default is none, meaning that validation is disabled. See Validation Options for more information.

 

 

Command-Line Name: -validatecommand

Database Name: validateCommand

Database Class: ValidateCommand

A script template to evaluate whenever validation is triggered. If set to the empty string (the default), validation is disabled. The script must return a boolean value. See Validation Options for more information.

 

 

Command-Line Name: -values

Database Name: values

Database Class: Values

Specifies the list of values to display in the drop-down listbox.

 

WIDGET COMMAND

In addition to the standard configure, cget, identify, instate, and state commands, combobox supports the following additional widget commands:

pathName bbox index

Returns a list of four numbers describing the bounding box of the character given by index. 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.

 

pathName current ?newIndex?

If newIndex is supplied, sets the combobox value to the element at position newIndex in the list of -values. Otherwise, returns the index of the current value in the list of -values or -1 if the current value does not appear in the list.

 

pathName delete first ?last?

Delete one or more elements of the combobox. First is the index of the first element to delete, and last is the index of the element just after the last one to delete. If last isn’t specified, it defaults to first+1, that is, a single element is deleted. This command returns the empty string.

pathName get

Returns the current value of the combobox.

 

pathName icursor index

Arrange for the insert cursor to be displayed just before the character given by index. Returns the empty string.

 

pathName index string

Returns the index of the given string in the combo box.

 

pathName insert index string

Inserts string just before the position indicated by index. Returns the empty string.

 

pathName invoke index

Invokes the action of the combobox selection.

 

pathName selection option arg

This command is used to adjust the selection within an entry. It has several forms, depending on option:

pathName selection clear

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 the empty string.

pathName selection present

Returns 1 if there is a selection in the combobox, 0 if nothing is selected.

pathName selection range start end

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

pathName set value

Sets the value of the combobox to value.

 

pathName xview args

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:

pathName xview

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 offscreen to the left, the middle 40% is visible in the window, and 40% of the text is offscreen to the right. These are the same values passed to scrollbars via the -xscrollcommand option.

 

pathName xview index

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

 

pathName xview moveto fraction

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

 

pathName xview scroll number what

This command shifts the view in the window left or right according to number and what. Number must be an integer. What must be either units or pages. If what 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 number is negative then characters farther to the left become visible; if it is positive then characters farther to the right become visible.

 

 

EXAMPLES

::hwtk::dialog .d -title "::hwtk::combobox"

set f [.d recess]

set cities [list Athens Berlin Brussels London Paris Vienna Zurich]

hwtk::label $f.l1 -text "Default"

hwtk::combobox $f.cb1 -values $cities -help "Capital Cities"

hwtk::label $f.l2 -text "Disabled"

hwtk::combobox $f.cb2 -values $cities -help "Capital Cities" -state disabled

grid columnconfigure $f 1 -weight 1

for {set i 1} {$i<=2} {incr i} {

    grid $f.l$i -row $i -col 0 -sticky w;

    grid $f.cb$i -row $i -col 1 -sticky e -pady 2

}

.d post