Documentation‎ > ‎Entries‎ > ‎

gnocl::comboEntry

gnocl::comboEntry [-option value...]

Screenshot

Options

-data string
User defined data which can be retrieved via the cget subcommand.
-hasFocus 1
This sets the focus to the widget. To unset the focus it must be set to another widget.
-items list of strings (default: "")
Creates for each element of this list a new item. The string value of the element is used as text and value of the item.
-itemValueList list of two-element-lists
Creates for each element of this list a new item. The first element of each element is used as text and the second element is used as value of the item.
-name string
Name of the widget, can be used to set options in an rc file.
-onChanged string (default: "")
Tcl command which is executed if the value of the option menu is changed via the GUI. Before evaluation the following percent strings are substituted:

%w    widget name
%v    value of the active item

NOTE: This command is not called if the value is changed via the option -value.
-onShowHelp string (default: "")
Tcl command which is executed in the global scope if the "show-help" signal is received, which is normally the case if the user presses F1 or Ctrl-F1. Before evaluation the following percent strings are substituted:

%w    widget name
%h    help type: either "whatsThis" or "tooltip"
-onPopupMenu string (default: "")
Tcl command which is executed if the "popup-menu" signal is received, which is normally the case if the user presses Shift-F10. Before evaluation the following percent strings are substituted:

%w    widget name.
-onRealize string (default: "")
Tcl command which is executed in the global scope if the widget has been realized. Before evaluation the following percent strings are substituted:

%w    widget name
-sensitive boolean (default: 1)
Whether or not the item is sensitive to user input.
-tooltip string
Message that appear next to this widget when the mouse pointer is held over it for a short amount of time.
-value  string
Value of the item which shall be activated
-variable string (default: "")
Name of a global variable which is changed whenever the option menu is changed.
-visible boolean (default: 1)
Whether or not the item is visible.

Description

This command is available since GTK+ 2.4. The comboEntry widget consists of a single-line text entry field and a drop-down list. The drop-down list is displayed when the user clicks on a small arrow button to the right of the entry field. Instead of a comboEntry widget with non-editable entry field, the use of the optionMenu is recommended.

Commands

id add text ?option?
Adds the given text to the current item list.
id cget option
Returns the value for one option. The option may have any of the values accepted by configure.
id configure [-option value...]
Configures the widget. Option may have any of the values accepted on creation of the widget.
id delete
Deletes the widget and the associated tcl command.
id onChanged
Executes the command given by the -onChanged option.
id cget option
Returns the value for one option. The option may have any of the values accepted by configure.
id configure [-option value...]
Configures the widget. Option may have any of the values accepted on creation of the widget.
id getEntry
Returns the widget-id of the object's embedded entry widget. Following this, the entry can be reconconfigured or commanded as a gnocl::entry object.

Example


set comboEntry [gnocl::comboEntry \
    -variable var \
    -items {"Cat" "Dog" "Bird"}]

gnocl::window \
    -title "ComboEntry" \
    -child $comboEntry

It may be the case that icons are desired in the entry widget of the combo box.

To achieve this, the most simplest method is to obtain the widget-id of the entry and reconfigure.


set label [gnocl::label \
    -baseFont {Sans 14} \
    -text ABC \
    -variable var \
    -tooltip "Show the content of variable 'var'."]

gnocl::window \
-title "Label" \
-child $label \
-x 800 -y 500 \
-width 240 -height 100


set comboEntry [gnocl::comboEntry \
-tooltip "Select an item in the list." \
-entryWidget $ent \
-variable var \
-items {"Cat" "Dog" "Bird"}]

# retrieve the entry wid and modify.
[$comboEntry getEntry] configure \
-tooltip "Type something new in here." \
-secondaryIcon %#Paste \
-secondaryIconTooltip "Paste Clipboard and Activate" \
-onIconPress { if {"%p" == "secondary" } { %w set [gnocl::clipboard getText] ; %w activate } else { %w clear } }

gnocl::window \
-x 800 -y 400 \
-width 240 \
-title "ComboEntry" \
-child $comboEntry



proc updateList {p t} {
set tmp(l) [$p cget -items]
set tmp(p) [lsearch $tmp(l) $t]
if { $tmp(p) != -1} { set tmp(l) [lreplace $tmp(l) $tmp(p) $tmp(p)] }
$p configure -items "$t $tmp(l)"
unset tmp

}

$comboEntry configure \
-variable tmp \
-baseColor yellow \
-data $comboEntry \
\
-onActivate { puts ACTIVATE ; set var %t } \
-onButtonPress { puts BUTTONPRESS } \
-onButtonRelease { puts BUTTONRELEASE } \
-onKeyPress { puts KEYPRESS }

$comboEntry set Giraffe

$comboEntry activate

set var ****



Comments