summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl.straw/lib/Tk/BrowseEntry.pod
blob: 98a547c4084afbf0ec91778a0740a1ba984fb660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210

=head1 NAME

Tk::BrowseEntry - entry widget with popup choices.

=for pm Tixish/BrowseEntry.pm

=for category Tix Extensions

=head1 SYNOPSIS

    use Tk::BrowseEntry;

    $b = $frame->BrowseEntry(-label => "Label", -variable => \$var);
    $b->insert("end", "opt1");
    $b->insert("end", "opt2");
    $b->insert("end", "opt3");
    ...
    $b->pack;

=head1 SUPER-CLASS

The C<BrowseEntry> class is derived from the C<Frame> class and
inherits all the methods, options and subwidgets of its super-class.
By default, options and methods are delegated to the entry subwidget.

=head1 DESCRIPTION

BrowseEntry is a poor man's ComboBox. It may be considered an
enhanced version of LabEntry which provides a button to popup the
choices of the possible values that the Entry may
take. BrowseEntry supports all the options LabEntry supports
except B<-textvariable>. This is replaced by B<-variable>. Other
options that BrowseEntry supports:

=over 4

=item B<-arrowimage>

Specifies the image to be used in the arrow button beside the entry
widget. The default is an downward arrow image in the file cbxarrow.xbm

=item B<-autolimitheight>

If set to a true value, then the height of the listbox will be at most
the number of entries in the list. The overall maximum of
C<-listheight> still applies.

=item B<-autolistwidth>

If set to a true value, then the width of the listbox will match the
width of the largest entry.

=item B<-browsecmd>

Specifies a function to call when a selection is made in the
popped up listbox. It is passed the widget and the text of the
entry selected. This function is called after the entry variable
has been assigned the value.

=item B<-browse2cmd>

Like C<-browsecmd>, but the callback is called with the listbox index
instead of the selected value.

=item B<-buttontakefocus>

Set the C<-takefocus> option of the button subwidget.

=item B<-choices>

Specifies the list of choices to pop up.  This is a reference to an
array of strings specifying the choices.

=item B<-colorstate>

The state of the widget is reflected by color. A non-editable entry
widget will get a light gray background, while an editable entry will
be almost white. [This may change]

=item B<-listcmd>

Specifies the function to call when the button next to the entry
is pressed to popup the choices in the listbox. This is called before
popping up the listbox, so can be used to populate the entries in
the listbox.

=item B<-listheight>

Set the height of the listbox. See also C<-autolimitheight>.

=item B<-listwidth>

Specifies the width of the popup listbox.

=item B<-state>

Specifies one of three states for the widget: normal, readonly, or
disabled.  If the widget is disabled then the value may not be changed
and the arrow button won't activate.  If the widget is readonly, the
entry may not be edited, but it may be changed by choosing a value
from the popup listbox.  normal is the default.

=item B<-style>

Set the "style" of the widget. Permitted values are C<MSWin32> and
C<unix>. By default C<-style> is set to the current platform. Widgets
with the C<unix> style will look like a normal C<BrowseEntry> widget,
whereas with the C<MSWin32> style the arrow will look close to the
Windows' standard combobox widget, while moving the mouse the entries
will be highlighted, and probably includes other changes.

=item B<-variable>

Specifies the variable in which the entered value is to be stored.

=back

=head1 METHODS

=over 4

=item B<insert(>I<index>, I<string>B<)>

Inserts the text of I<string> at the specified I<index>. This string
then becomes available as one of the choices.

=item B<delete(>I<index1>, I<index2>B<)>

Deletes items from I<index1> to I<index2>.

=item B<get>

The get method is delegated to the choices listbox.

=back

=head1 ADVERTISED WIDGETS

The following widgets are advertised:

=over

=item entry

The entry widget.

=item arrow

The button with the arrow image.

=item choices

The toplevel widget containing the choice listbox.

=item slistbox

The scrolled listbox with the choices.

=back

=head1 SUBCLASSING

To make subclassing easier, the following methods may be overridden to
use other standard widgets in composing the mega widget:

=over

=item LabEntryWidget

A widget class compatible with Tk::LabEntry used for the entry.

=item ButtonWidget

A widget class compatible with Tk::Button used for the arrow button.

=item ListboxWidget

A widget class compatible with Tk::Listbox used for the choices
listbox.

=back

For example to use a C<NumEntry> widget (from the Tk-GBARR CPAN
distribution) instead of the normal C<Entry> widget:

    package Tk::NumBrowseEntry;
    use base qw(Tk::BrowseEntry);
    use Tk::NumEntry;
    Construct Tk::Widget 'NumBrowseEntry';
    sub LabEntryWidget { "NumEntry" }

=head1 BUGS

BrowseEntry should really provide more of the ComboBox options.

=head1 AUTHOR

B<Rajappa Iyer> rsi@earthling.net

B<Chris Dean> ctdean@cogit.com made additions.

More additions by B<Slaven Rezic> slaven@rezic.de

This code was inspired by ComboBox.tcl in Tix4.0 by Ioi Lam and
bears more than a passing resemblance to ComboBox code. This may
be distributed under the same conditions as Perl.

=cut