1BrowseEntry(3)        User Contributed Perl Documentation       BrowseEntry(3)
2
3
4

NAME

6       Tk::BrowseEntry - entry widget with popup choices.
7

SYNOPSIS

9           use Tk::BrowseEntry;
10
11           $b = $frame->BrowseEntry(-label => "Label", -variable => \$var);
12           $b->insert("end", "opt1");
13           $b->insert("end", "opt2");
14           $b->insert("end", "opt3");
15           ...
16           $b->pack;
17

SUPER-CLASS

19       The "BrowseEntry" class is derived from the "Frame" class and inherits
20       all the methods, options and subwidgets of its super-class.  By
21       default, options and methods are delegated to the entry subwidget.
22

DESCRIPTION

24       BrowseEntry is a poor man's ComboBox. It may be considered an enhanced
25       version of LabEntry which provides a button to popup the choices of the
26       possible values that the Entry may take. BrowseEntry supports all the
27       options LabEntry supports except -textvariable. This is replaced by
28       -variable. Other options that BrowseEntry supports:
29
30       -arrowimage
31           Specifies the image to be used in the arrow button beside the entry
32           widget. The default is an downward arrow image in the file
33           cbxarrow.xbm
34
35       -autolimitheight
36           If set to a true value, then the height of the listbox will be at
37           most the number of entries in the list. The overall maximum of
38           "-listheight" still applies.
39
40       -autolistwidth
41           If set to a true value, then the width of the listbox will match
42           the width of the largest entry.
43
44       -browsecmd
45           Specifies a function to call when a selection is made in the popped
46           up listbox. It is passed the widget and the text of the entry
47           selected. This function is called after the entry variable has been
48           assigned the value.
49
50       -browse2cmd
51           Like "-browsecmd", but the callback is called with the listbox
52           index instead of the selected value.
53
54       -buttontakefocus
55           Set the "-takefocus" option of the button subwidget.
56
57       -choices
58           Specifies the list of choices to pop up.  This is a reference to an
59           array of strings specifying the choices.
60
61       -colorstate
62           The state of the widget is reflected by color. A non-editable entry
63           widget will get a light gray background, while an editable entry
64           will be almost white. [This may change]
65
66       -listcmd
67           Specifies the function to call when the button next to the entry is
68           pressed to popup the choices in the listbox. This is called before
69           popping up the listbox, so can be used to populate the entries in
70           the listbox.
71
72       -listheight
73           Set the height of the listbox. See also "-autolimitheight".
74
75       -listwidth
76           Specifies the width of the popup listbox.
77
78       -state
79           Specifies one of three states for the widget: normal, readonly, or
80           disabled.  If the widget is disabled then the value may not be
81           changed and the arrow button won't activate.  If the widget is
82           readonly, the entry may not be edited, but it may be changed by
83           choosing a value from the popup listbox.  normal is the default.
84
85       -style
86           Set the "style" of the widget. Permitted values are "MSWin32" and
87           "unix". By default "-style" is set to the current platform. Widgets
88           with the "unix" style will look like a normal "BrowseEntry" widget,
89           whereas with the "MSWin32" style the arrow will look close to the
90           Windows' standard combobox widget, while moving the mouse the
91           entries will be highlighted, and probably includes other changes.
92
93       -variable
94           Specifies the variable in which the entered value is to be stored.
95

METHODS

97       insert(index, string)
98           Inserts the text of string at the specified index. This string then
99           becomes available as one of the choices.
100
101       delete(index1, index2)
102           Deletes items from index1 to index2.
103
104       get The get method is delegated to the choices listbox.
105

ADVERTISED WIDGETS

107       The following widgets are advertised:
108
109       entry
110           The entry widget.
111
112       arrow
113           The button with the arrow image.
114
115       choices
116           The toplevel widget containing the choice listbox.
117
118       slistbox
119           The scrolled listbox with the choices.
120

SUBCLASSING

122       To make subclassing easier, the following methods may be overridden to
123       use other standard widgets in composing the mega widget:
124
125       LabEntryWidget
126           A widget class compatible with Tk::LabEntry used for the entry.
127
128       ButtonWidget
129           A widget class compatible with Tk::Button used for the arrow
130           button.
131
132       ListboxWidget
133           A widget class compatible with Tk::Listbox used for the choices
134           listbox.
135
136       For example to use a "NumEntry" widget (from the Tk-GBARR CPAN
137       distribution) instead of the normal "Entry" widget:
138
139           package Tk::NumBrowseEntry;
140           use base qw(Tk::BrowseEntry);
141           use Tk::NumEntry;
142           Construct Tk::Widget 'NumBrowseEntry';
143           sub LabEntryWidget { "NumEntry" }
144

BUGS

146       BrowseEntry should really provide more of the ComboBox options.
147

AUTHOR

149       Rajappa Iyer rsi@earthling.net
150
151       Chris Dean ctdean@cogit.com made additions.
152
153       More additions by Slaven Rezic slaven@rezic.de
154
155       This code was inspired by ComboBox.tcl in Tix4.0 by Ioi Lam and bears
156       more than a passing resemblance to ComboBox code. This may be
157       distributed under the same conditions as Perl.
158
159
160
161perl v5.32.0                      2020-07-28                    BrowseEntry(3)
Impressum