| 1 | '\" |
| 2 | '\" Copyright (c) 1990 The Regents of the University of California. |
| 3 | '\" Copyright (c) 1994-1997 Sun Microsystems, Inc. |
| 4 | '\" |
| 5 | '\" See the file "license.terms" for information on usage and redistribution |
| 6 | '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 7 | '\" |
| 8 | '\" RCS: @(#) $Id: listbox.n,v 1.9.2.1 2004/10/28 10:19:29 dkf Exp $ |
| 9 | '\" |
| 10 | '\" The definitions below are for supplemental macros used in Tcl/Tk |
| 11 | '\" manual entries. |
| 12 | '\" |
| 13 | '\" .AP type name in/out ?indent? |
| 14 | '\" Start paragraph describing an argument to a library procedure. |
| 15 | '\" type is type of argument (int, etc.), in/out is either "in", "out", |
| 16 | '\" or "in/out" to describe whether procedure reads or modifies arg, |
| 17 | '\" and indent is equivalent to second arg of .IP (shouldn't ever be |
| 18 | '\" needed; use .AS below instead) |
| 19 | '\" |
| 20 | '\" .AS ?type? ?name? |
| 21 | '\" Give maximum sizes of arguments for setting tab stops. Type and |
| 22 | '\" name are examples of largest possible arguments that will be passed |
| 23 | '\" to .AP later. If args are omitted, default tab stops are used. |
| 24 | '\" |
| 25 | '\" .BS |
| 26 | '\" Start box enclosure. From here until next .BE, everything will be |
| 27 | '\" enclosed in one large box. |
| 28 | '\" |
| 29 | '\" .BE |
| 30 | '\" End of box enclosure. |
| 31 | '\" |
| 32 | '\" .CS |
| 33 | '\" Begin code excerpt. |
| 34 | '\" |
| 35 | '\" .CE |
| 36 | '\" End code excerpt. |
| 37 | '\" |
| 38 | '\" .VS ?version? ?br? |
| 39 | '\" Begin vertical sidebar, for use in marking newly-changed parts |
| 40 | '\" of man pages. The first argument is ignored and used for recording |
| 41 | '\" the version when the .VS was added, so that the sidebars can be |
| 42 | '\" found and removed when they reach a certain age. If another argument |
| 43 | '\" is present, then a line break is forced before starting the sidebar. |
| 44 | '\" |
| 45 | '\" .VE |
| 46 | '\" End of vertical sidebar. |
| 47 | '\" |
| 48 | '\" .DS |
| 49 | '\" Begin an indented unfilled display. |
| 50 | '\" |
| 51 | '\" .DE |
| 52 | '\" End of indented unfilled display. |
| 53 | '\" |
| 54 | '\" .SO |
| 55 | '\" Start of list of standard options for a Tk widget. The |
| 56 | '\" options follow on successive lines, in four columns separated |
| 57 | '\" by tabs. |
| 58 | '\" |
| 59 | '\" .SE |
| 60 | '\" End of list of standard options for a Tk widget. |
| 61 | '\" |
| 62 | '\" .OP cmdName dbName dbClass |
| 63 | '\" Start of description of a specific option. cmdName gives the |
| 64 | '\" option's name as specified in the class command, dbName gives |
| 65 | '\" the option's name in the option database, and dbClass gives |
| 66 | '\" the option's class in the option database. |
| 67 | '\" |
| 68 | '\" .UL arg1 arg2 |
| 69 | '\" Print arg1 underlined, then print arg2 normally. |
| 70 | '\" |
| 71 | '\" RCS: @(#) $Id: man.macros,v 1.4 2000/08/25 06:18:32 ericm Exp $ |
| 72 | '\" |
| 73 | '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. |
| 74 | .if t .wh -1.3i ^B |
| 75 | .nr ^l \n(.l |
| 76 | .ad b |
| 77 | '\" # Start an argument description |
| 78 | .de AP |
| 79 | .ie !"\\$4"" .TP \\$4 |
| 80 | .el \{\ |
| 81 | . ie !"\\$2"" .TP \\n()Cu |
| 82 | . el .TP 15 |
| 83 | .\} |
| 84 | .ta \\n()Au \\n()Bu |
| 85 | .ie !"\\$3"" \{\ |
| 86 | \&\\$1 \\fI\\$2\\fP (\\$3) |
| 87 | .\".b |
| 88 | .\} |
| 89 | .el \{\ |
| 90 | .br |
| 91 | .ie !"\\$2"" \{\ |
| 92 | \&\\$1 \\fI\\$2\\fP |
| 93 | .\} |
| 94 | .el \{\ |
| 95 | \&\\fI\\$1\\fP |
| 96 | .\} |
| 97 | .\} |
| 98 | .. |
| 99 | '\" # define tabbing values for .AP |
| 100 | .de AS |
| 101 | .nr )A 10n |
| 102 | .if !"\\$1"" .nr )A \\w'\\$1'u+3n |
| 103 | .nr )B \\n()Au+15n |
| 104 | .\" |
| 105 | .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n |
| 106 | .nr )C \\n()Bu+\\w'(in/out)'u+2n |
| 107 | .. |
| 108 | .AS Tcl_Interp Tcl_CreateInterp in/out |
| 109 | '\" # BS - start boxed text |
| 110 | '\" # ^y = starting y location |
| 111 | '\" # ^b = 1 |
| 112 | .de BS |
| 113 | .br |
| 114 | .mk ^y |
| 115 | .nr ^b 1u |
| 116 | .if n .nf |
| 117 | .if n .ti 0 |
| 118 | .if n \l'\\n(.lu\(ul' |
| 119 | .if n .fi |
| 120 | .. |
| 121 | '\" # BE - end boxed text (draw box now) |
| 122 | .de BE |
| 123 | .nf |
| 124 | .ti 0 |
| 125 | .mk ^t |
| 126 | .ie n \l'\\n(^lu\(ul' |
| 127 | .el \{\ |
| 128 | .\" Draw four-sided box normally, but don't draw top of |
| 129 | .\" box if the box started on an earlier page. |
| 130 | .ie !\\n(^b-1 \{\ |
| 131 | \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' |
| 132 | .\} |
| 133 | .el \}\ |
| 134 | \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' |
| 135 | .\} |
| 136 | .\} |
| 137 | .fi |
| 138 | .br |
| 139 | .nr ^b 0 |
| 140 | .. |
| 141 | '\" # VS - start vertical sidebar |
| 142 | '\" # ^Y = starting y location |
| 143 | '\" # ^v = 1 (for troff; for nroff this doesn't matter) |
| 144 | .de VS |
| 145 | .if !"\\$2"" .br |
| 146 | .mk ^Y |
| 147 | .ie n 'mc \s12\(br\s0 |
| 148 | .el .nr ^v 1u |
| 149 | .. |
| 150 | '\" # VE - end of vertical sidebar |
| 151 | .de VE |
| 152 | .ie n 'mc |
| 153 | .el \{\ |
| 154 | .ev 2 |
| 155 | .nf |
| 156 | .ti 0 |
| 157 | .mk ^t |
| 158 | \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' |
| 159 | .sp -1 |
| 160 | .fi |
| 161 | .ev |
| 162 | .\} |
| 163 | .nr ^v 0 |
| 164 | .. |
| 165 | '\" # Special macro to handle page bottom: finish off current |
| 166 | '\" # box/sidebar if in box/sidebar mode, then invoked standard |
| 167 | '\" # page bottom macro. |
| 168 | .de ^B |
| 169 | .ev 2 |
| 170 | 'ti 0 |
| 171 | 'nf |
| 172 | .mk ^t |
| 173 | .if \\n(^b \{\ |
| 174 | .\" Draw three-sided box if this is the box's first page, |
| 175 | .\" draw two sides but no top otherwise. |
| 176 | .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c |
| 177 | .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c |
| 178 | .\} |
| 179 | .if \\n(^v \{\ |
| 180 | .nr ^x \\n(^tu+1v-\\n(^Yu |
| 181 | \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c |
| 182 | .\} |
| 183 | .bp |
| 184 | 'fi |
| 185 | .ev |
| 186 | .if \\n(^b \{\ |
| 187 | .mk ^y |
| 188 | .nr ^b 2 |
| 189 | .\} |
| 190 | .if \\n(^v \{\ |
| 191 | .mk ^Y |
| 192 | .\} |
| 193 | .. |
| 194 | '\" # DS - begin display |
| 195 | .de DS |
| 196 | .RS |
| 197 | .nf |
| 198 | .sp |
| 199 | .. |
| 200 | '\" # DE - end display |
| 201 | .de DE |
| 202 | .fi |
| 203 | .RE |
| 204 | .sp |
| 205 | .. |
| 206 | '\" # SO - start of list of standard options |
| 207 | .de SO |
| 208 | .SH "STANDARD OPTIONS" |
| 209 | .LP |
| 210 | .nf |
| 211 | .ta 5.5c 11c |
| 212 | .ft B |
| 213 | .. |
| 214 | '\" # SE - end of list of standard options |
| 215 | .de SE |
| 216 | .fi |
| 217 | .ft R |
| 218 | .LP |
| 219 | See the \\fBoptions\\fR manual entry for details on the standard options. |
| 220 | .. |
| 221 | '\" # OP - start of full description for a single option |
| 222 | .de OP |
| 223 | .LP |
| 224 | .nf |
| 225 | .ta 4c |
| 226 | Command-Line Name: \\fB\\$1\\fR |
| 227 | Database Name: \\fB\\$2\\fR |
| 228 | Database Class: \\fB\\$3\\fR |
| 229 | .fi |
| 230 | .IP |
| 231 | .. |
| 232 | '\" # CS - begin code excerpt |
| 233 | .de CS |
| 234 | .RS |
| 235 | .nf |
| 236 | .ta .25i .5i .75i 1i |
| 237 | .. |
| 238 | '\" # CE - end code excerpt |
| 239 | .de CE |
| 240 | .fi |
| 241 | .RE |
| 242 | .. |
| 243 | .de UL |
| 244 | \\$1\l'|0\(ul'\\$2 |
| 245 | .. |
| 246 | .TH listbox n 8.4 Tk "Tk Built-In Commands" |
| 247 | .BS |
| 248 | '\" Note: do not modify the .SH NAME line immediately below! |
| 249 | .SH NAME |
| 250 | listbox \- Create and manipulate listbox widgets |
| 251 | .SH SYNOPSIS |
| 252 | \fBlistbox\fR \fIpathName \fR?\fIoptions\fR? |
| 253 | .SO |
| 254 | \-activestyle \-height \-selectforeground |
| 255 | \-background \-highlightbackground \-setgrid |
| 256 | \-borderwidth \-highlightcolor \-state |
| 257 | \-cursor \-highlightthickness \-takefocus |
| 258 | \-disabledforeground \-relief \-width |
| 259 | \-exportselection \-selectbackground \-xscrollcommand |
| 260 | \-font \-selectborderwidth \-yscrollcommand |
| 261 | \-foreground |
| 262 | .SE |
| 263 | .SH "WIDGET-SPECIFIC OPTIONS" |
| 264 | .VS 8.4 |
| 265 | .OP \-activestyle activeStyle ActiveStyle |
| 266 | Specifies the style in which to draw the active element. This must be |
| 267 | one of \fBdotbox\fR (show a focus ring around the active element), |
| 268 | \fBnone\fR (no special indication of active element) or |
| 269 | \fBunderline\fR (underline the active element). |
| 270 | The default is \fBunderline\fR. |
| 271 | .VS 8.4 |
| 272 | .OP \-height height Height |
| 273 | Specifies the desired height for the window, in lines. |
| 274 | If zero or less, then the desired height for the window is made just |
| 275 | large enough to hold all the elements in the listbox. |
| 276 | .OP \-listvariable listVariable Variable |
| 277 | Specifies the name of a variable. The value of the variable is a list to |
| 278 | be displayed inside the widget; if the variable value changes then the |
| 279 | widget will automatically update itself to reflect the new value. Attempts |
| 280 | to assign a variable with an invalid list value to \fB\-listvariable\fR |
| 281 | will cause an error. Attempts to unset a variable in use as a |
| 282 | \fB\-listvariable\fR will fail but will not generate an error. |
| 283 | .OP \-selectmode selectMode SelectMode |
| 284 | Specifies one of several styles for manipulating the selection. |
| 285 | The value of the option may be arbitrary, but the default bindings |
| 286 | expect it to be either \fBsingle\fR, \fBbrowse\fR, \fBmultiple\fR, |
| 287 | or \fBextended\fR; the default value is \fBbrowse\fR. |
| 288 | .OP \-state state State |
| 289 | Specifies one of two states for the listbox: \fBnormal\fR or \fBdisabled\fR. |
| 290 | If the listbox is disabled then items may not be inserted or deleted, |
| 291 | items are drawn in the \fB-disabledforeground\fR color, and selection |
| 292 | cannot be modified and is not shown (though selection information is retained). |
| 293 | .OP \-width width Width |
| 294 | Specifies the desired width for the window in characters. |
| 295 | If the font doesn't have a uniform width then the width of the |
| 296 | character ``0'' is used in translating from character units to |
| 297 | screen units. |
| 298 | If zero or less, then the desired width for the window is made just |
| 299 | large enough to hold all the elements in the listbox. |
| 300 | .BE |
| 301 | |
| 302 | .SH DESCRIPTION |
| 303 | .PP |
| 304 | The \fBlistbox\fR command creates a new window (given by the |
| 305 | \fIpathName\fR argument) and makes it into a listbox widget. |
| 306 | Additional |
| 307 | options, described above, may be specified on the command line |
| 308 | or in the option database |
| 309 | to configure aspects of the listbox such as its colors, font, |
| 310 | text, and relief. The \fBlistbox\fR command returns its |
| 311 | \fIpathName\fR argument. At the time this command is invoked, |
| 312 | there must not exist a window named \fIpathName\fR, but |
| 313 | \fIpathName\fR's parent must exist. |
| 314 | .PP |
| 315 | A listbox is a widget that displays a list of strings, one per line. |
| 316 | When first created, a new listbox has no elements. |
| 317 | Elements may be added or deleted using widget commands described |
| 318 | below. In addition, one or more elements may be selected as described |
| 319 | below. |
| 320 | If a listbox is exporting its selection (see \fBexportSelection\fR |
| 321 | option), then it will observe the standard X11 protocols |
| 322 | for handling the selection. |
| 323 | Listbox selections are available as type \fBSTRING\fR; |
| 324 | the value of the selection will be the text of the selected elements, with |
| 325 | newlines separating the elements. |
| 326 | .PP |
| 327 | It is not necessary for all the elements to be |
| 328 | displayed in the listbox window at once; commands described below |
| 329 | may be used to change the view in the window. Listboxes allow |
| 330 | scrolling in both directions using the standard \fBxScrollCommand\fR |
| 331 | and \fByScrollCommand\fR options. |
| 332 | They also support scanning, as described below. |
| 333 | |
| 334 | .SH "INDICES" |
| 335 | .PP |
| 336 | Many of the widget commands for listboxes take one or more indices |
| 337 | as arguments. |
| 338 | An index specifies a particular element of the listbox, in any of |
| 339 | the following ways: |
| 340 | .TP 12 |
| 341 | \fInumber\fR |
| 342 | Specifies the element as a numerical index, where 0 corresponds |
| 343 | to the first element in the listbox. |
| 344 | .TP 12 |
| 345 | \fBactive\fR |
| 346 | Indicates the element that has the location cursor. This element |
| 347 | will be displayed as specified by \fB\-activestyle\fR when the listbox |
| 348 | has the keyboard focus, and it is specified with the \fBactivate\fR |
| 349 | widget command. |
| 350 | .TP 12 |
| 351 | \fBanchor\fR |
| 352 | Indicates the anchor point for the selection, which is set with the |
| 353 | \fBselection anchor\fR widget command. |
| 354 | .TP 12 |
| 355 | \fBend\fR |
| 356 | Indicates the end of the listbox. |
| 357 | .VS 8.0 |
| 358 | For most commands this refers to the last element in the listbox, |
| 359 | but for a few commands such as \fBindex\fR and \fBinsert\fR |
| 360 | it refers to the element just after the last one. |
| 361 | .VE |
| 362 | .TP 12 |
| 363 | \fB@\fIx\fB,\fIy\fR |
| 364 | Indicates the element that covers the point in the listbox window |
| 365 | specified by \fIx\fR and \fIy\fR (in pixel coordinates). If no |
| 366 | element covers that point, then the closest element to that |
| 367 | point is used. |
| 368 | .LP |
| 369 | In the widget command descriptions below, arguments named \fIindex\fR, |
| 370 | \fIfirst\fR, and \fIlast\fR always contain text indices in one of |
| 371 | the above forms. |
| 372 | |
| 373 | .SH "WIDGET COMMAND" |
| 374 | .PP |
| 375 | The \fBlistbox\fR command creates a new Tcl command whose |
| 376 | name is \fIpathName\fR. This |
| 377 | command may be used to invoke various |
| 378 | operations on the widget. It has the following general form: |
| 379 | .CS |
| 380 | \fIpathName option \fR?\fIarg arg ...\fR? |
| 381 | .CE |
| 382 | \fIOption\fR and the \fIarg\fRs |
| 383 | determine the exact behavior of the command. The following |
| 384 | commands are possible for listbox widgets: |
| 385 | .TP |
| 386 | \fIpathName \fBactivate\fR \fIindex\fR |
| 387 | Sets the active element to the one indicated by \fIindex\fR. |
| 388 | .VS 8.0 |
| 389 | If \fIindex\fR is outside the range of elements in the listbox |
| 390 | then the closest element is activated. |
| 391 | .VE |
| 392 | The active element is drawn as specified by \fB\-activestyle\fR when the |
| 393 | widget has the input focus, and its index may be retrieved with the |
| 394 | index \fBactive\fR. |
| 395 | .TP |
| 396 | \fIpathName \fBbbox\fR \fIindex\fR |
| 397 | Returns a list of four numbers describing the bounding box of |
| 398 | the text in the element given by \fIindex\fR. |
| 399 | The first two elements of the list give the x and y coordinates |
| 400 | of the upper-left corner of the screen area covered by the text |
| 401 | (specified in pixels relative to the widget) and the last two |
| 402 | elements give the width and height of the area, in pixels. |
| 403 | If no part of the element given by \fIindex\fR is visible on the |
| 404 | screen, |
| 405 | .VS 8.0 |
| 406 | or if \fIindex\fR refers to a non-existent element, |
| 407 | .VE |
| 408 | then the result is an empty string; if the element is |
| 409 | partially visible, the result gives the full area of the element, |
| 410 | including any parts that are not visible. |
| 411 | .TP |
| 412 | \fIpathName \fBcget\fR \fIoption\fR |
| 413 | Returns the current value of the configuration option given |
| 414 | by \fIoption\fR. |
| 415 | \fIOption\fR may have any of the values accepted by the \fBlistbox\fR |
| 416 | command. |
| 417 | .TP |
| 418 | \fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? |
| 419 | Query or modify the configuration options of the widget. |
| 420 | If no \fIoption\fR is specified, returns a list describing all of |
| 421 | the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for |
| 422 | information on the format of this list). If \fIoption\fR is specified |
| 423 | with no \fIvalue\fR, then the command returns a list describing the |
| 424 | one named option (this list will be identical to the corresponding |
| 425 | sublist of the value returned if no \fIoption\fR is specified). If |
| 426 | one or more \fIoption\-value\fR pairs are specified, then the command |
| 427 | modifies the given widget option(s) to have the given value(s); in |
| 428 | this case the command returns an empty string. |
| 429 | \fIOption\fR may have any of the values accepted by the \fBlistbox\fR |
| 430 | command. |
| 431 | .TP |
| 432 | \fIpathName \fBcurselection\fR |
| 433 | Returns a list containing the numerical indices of |
| 434 | all of the elements in the listbox that are currently selected. |
| 435 | If there are no elements selected in the listbox then an empty |
| 436 | string is returned. |
| 437 | .TP |
| 438 | \fIpathName \fBdelete \fIfirst \fR?\fIlast\fR? |
| 439 | Deletes one or more elements of the listbox. \fIFirst\fR and \fIlast\fR |
| 440 | are indices specifying the first and last elements in the range |
| 441 | to delete. If \fIlast\fR isn't specified it defaults to |
| 442 | \fIfirst\fR, i.e. a single element is deleted. |
| 443 | .TP |
| 444 | \fIpathName \fBget \fIfirst\fR ?\fIlast\fR? |
| 445 | If \fIlast\fR is omitted, returns the contents of the listbox |
| 446 | element indicated by \fIfirst\fR, |
| 447 | .VS 8.0 |
| 448 | or an empty string if \fIfirst\fR refers to a non-existent element. |
| 449 | .VE |
| 450 | If \fIlast\fR is specified, the command returns a list whose elements |
| 451 | are all of the listbox elements between \fIfirst\fR and \fIlast\fR, |
| 452 | inclusive. |
| 453 | Both \fIfirst\fR and \fIlast\fR may have any of the standard |
| 454 | forms for indices. |
| 455 | .TP |
| 456 | \fIpathName \fBindex \fIindex\fR |
| 457 | Returns the integer index value that corresponds to \fIindex\fR. |
| 458 | .VS 8.0 |
| 459 | If \fIindex\fR is \fBend\fR the return value is a count of the number |
| 460 | of elements in the listbox (not the index of the last element). |
| 461 | .VE |
| 462 | .TP |
| 463 | \fIpathName \fBinsert \fIindex \fR?\fIelement element ...\fR? |
| 464 | Inserts zero or more new elements in the list just before the |
| 465 | element given by \fIindex\fR. If \fIindex\fR is specified as |
| 466 | \fBend\fR then the new elements are added to the end of the |
| 467 | list. Returns an empty string. |
| 468 | .TP |
| 469 | \fIpathName \fBitemcget \fIindex option\fR |
| 470 | Returns the current value of the item configuration option given |
| 471 | by \fIoption\fR. \fIOption\fR may have any of the values accepted |
| 472 | by the \fBlistbox itemconfigure\fR command. |
| 473 | .TP |
| 474 | \fIpathName \fBitemconfigure \fIindex\fR ?\fIoption\fR? ?\fIvalue\fR? ?\fIoption value ...\fR? |
| 475 | Query or modify the configuration options of an item in the listbox. |
| 476 | If no \fIoption\fR is specified, returns a list describing all of |
| 477 | the available options for the item (see \fBTk_ConfigureInfo\fR for |
| 478 | information on the format of this list). If \fIoption\fR is specified |
| 479 | with no \fIvalue\fR, then the command returns a list describing the |
| 480 | one named option (this list will be identical to the corresponding |
| 481 | sublist of the value returned if no \fIoption\fR is specified). If |
| 482 | one or more \fIoption\-value\fR pairs are specified, then the command |
| 483 | modifies the given widget option(s) to have the given value(s); in |
| 484 | this case the command returns an empty string. The following options |
| 485 | are currently supported for items: |
| 486 | .RS |
| 487 | .TP |
| 488 | \fB\-background \fIcolor\fR |
| 489 | \fIColor\fR specifies the background color to use when displaying the |
| 490 | item. It may have any of the forms accepted by \fBTk_GetColor\fR. |
| 491 | .TP |
| 492 | \fB\-foreground \fIcolor\fR |
| 493 | \fIColor\fR specifies the foreground color to use when displaying the |
| 494 | item. It may have any of the forms accepted by \fBTk_GetColor\fR. |
| 495 | .TP |
| 496 | \fB\-selectbackground \fIcolor\fR |
| 497 | \fIcolor\fR specifies the background color to use when displaying the |
| 498 | item while it is selected. It may have any of the forms accepted by |
| 499 | \fBTk_GetColor\fR. |
| 500 | .TP |
| 501 | \fB\-selectforeground \fIcolor\fR |
| 502 | \fIcolor\fR specifies the foreground color to use when displaying the |
| 503 | item while it is selected. It may have any of the forms accepted by |
| 504 | \fBTk_GetColor\fR. |
| 505 | .RE |
| 506 | .TP |
| 507 | \fIpathName \fBnearest \fIy\fR |
| 508 | Given a y-coordinate within the listbox window, this command returns |
| 509 | the index of the (visible) listbox element nearest to that y-coordinate. |
| 510 | .TP |
| 511 | \fIpathName \fBscan\fR \fIoption args\fR |
| 512 | This command is used to implement scanning on listboxes. It has |
| 513 | two forms, depending on \fIoption\fR: |
| 514 | .RS |
| 515 | .TP |
| 516 | \fIpathName \fBscan mark \fIx y\fR |
| 517 | Records \fIx\fR and \fIy\fR and the current view in the listbox |
| 518 | window; used in conjunction with later \fBscan dragto\fR commands. |
| 519 | Typically this command is associated with a mouse button press in |
| 520 | the widget. It returns an empty string. |
| 521 | .TP |
| 522 | \fIpathName \fBscan dragto \fIx y\fR. |
| 523 | This command computes the difference between its \fIx\fR and \fIy\fR |
| 524 | arguments and the \fIx\fR and \fIy\fR arguments to the last |
| 525 | \fBscan mark\fR command for the widget. |
| 526 | It then adjusts the view by 10 times the |
| 527 | difference in coordinates. This command is typically associated |
| 528 | with mouse motion events in the widget, to produce the effect of |
| 529 | dragging the list at high speed through the window. The return |
| 530 | value is an empty string. |
| 531 | .RE |
| 532 | .TP |
| 533 | \fIpathName \fBsee \fIindex\fR |
| 534 | Adjust the view in the listbox so that the element given by \fIindex\fR |
| 535 | is visible. |
| 536 | If the element is already visible then the command has no effect; |
| 537 | if the element is near one edge of the window then the listbox |
| 538 | scrolls to bring the element into view at the edge; otherwise |
| 539 | the listbox scrolls to center the element. |
| 540 | .TP |
| 541 | \fIpathName \fBselection \fIoption arg\fR |
| 542 | This command is used to adjust the selection within a listbox. It |
| 543 | has several forms, depending on \fIoption\fR: |
| 544 | .RS |
| 545 | .TP |
| 546 | \fIpathName \fBselection anchor \fIindex\fR |
| 547 | Sets the selection anchor to the element given by \fIindex\fR. |
| 548 | .VS 8.0 |
| 549 | If \fIindex\fR refers to a non-existent element, then the closest |
| 550 | element is used. |
| 551 | .VE |
| 552 | The selection anchor is the end of the selection that is fixed |
| 553 | while dragging out a selection with the mouse. |
| 554 | The index \fBanchor\fR may be used to refer to the anchor |
| 555 | element. |
| 556 | .TP |
| 557 | \fIpathName \fBselection clear \fIfirst \fR?\fIlast\fR? |
| 558 | If any of the elements between \fIfirst\fR and \fIlast\fR |
| 559 | (inclusive) are selected, they are deselected. |
| 560 | The selection state is not changed for elements outside |
| 561 | this range. |
| 562 | .TP |
| 563 | \fIpathName \fBselection includes \fIindex\fR |
| 564 | Returns 1 if the element indicated by \fIindex\fR is currently |
| 565 | selected, 0 if it isn't. |
| 566 | .TP |
| 567 | \fIpathName \fBselection set \fIfirst \fR?\fIlast\fR? |
| 568 | Selects all of the elements in the range between |
| 569 | \fIfirst\fR and \fIlast\fR, inclusive, without affecting |
| 570 | the selection state of elements outside that range. |
| 571 | .RE |
| 572 | .TP |
| 573 | \fIpathName \fBsize\fR |
| 574 | Returns a decimal string indicating the total number of elements |
| 575 | in the listbox. |
| 576 | .TP |
| 577 | \fIpathName \fBxview \fIargs\fR |
| 578 | This command is used to query and change the horizontal position of the |
| 579 | information in the widget's window. It can take any of the following |
| 580 | forms: |
| 581 | .RS |
| 582 | .TP |
| 583 | \fIpathName \fBxview\fR |
| 584 | Returns a list containing two elements. |
| 585 | Each element is a real fraction between 0 and 1; together they describe |
| 586 | the horizontal span that is visible in the window. |
| 587 | For example, if the first element is .2 and the second element is .6, |
| 588 | 20% of the listbox's text is off-screen to the left, the middle 40% is visible |
| 589 | in the window, and 40% of the text is off-screen to the right. |
| 590 | These are the same values passed to scrollbars via the \fB\-xscrollcommand\fR |
| 591 | option. |
| 592 | .TP |
| 593 | \fIpathName \fBxview\fR \fIindex\fR |
| 594 | Adjusts the view in the window so that the character position given by |
| 595 | \fIindex\fR is displayed at the left edge of the window. |
| 596 | Character positions are defined by the width of the character \fB0\fR. |
| 597 | .TP |
| 598 | \fIpathName \fBxview moveto\fI fraction\fR |
| 599 | Adjusts the view in the window so that \fIfraction\fR of the |
| 600 | total width of the listbox text is off-screen to the left. |
| 601 | \fIfraction\fR must be a fraction between 0 and 1. |
| 602 | .TP |
| 603 | \fIpathName \fBxview scroll \fInumber what\fR |
| 604 | This command shifts the view in the window left or right according to |
| 605 | \fInumber\fR and \fIwhat\fR. |
| 606 | \fINumber\fR must be an integer. |
| 607 | \fIWhat\fR must be either \fBunits\fR or \fBpages\fR or an abbreviation |
| 608 | of one of these. |
| 609 | If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by |
| 610 | \fInumber\fR character units (the width of the \fB0\fR character) |
| 611 | on the display; if it is \fBpages\fR then the view adjusts by |
| 612 | \fInumber\fR screenfuls. |
| 613 | If \fInumber\fR is negative then characters farther to the left |
| 614 | become visible; if it is positive then characters farther to the right |
| 615 | become visible. |
| 616 | .RE |
| 617 | .TP |
| 618 | \fIpathName \fByview \fI?args\fR? |
| 619 | This command is used to query and change the vertical position of the |
| 620 | text in the widget's window. |
| 621 | It can take any of the following forms: |
| 622 | .RS |
| 623 | .TP |
| 624 | \fIpathName \fByview\fR |
| 625 | Returns a list containing two elements, both of which are real fractions |
| 626 | between 0 and 1. |
| 627 | The first element gives the position of the listbox element at the |
| 628 | top of the window, relative to the listbox as a whole (0.5 means |
| 629 | it is halfway through the listbox, for example). |
| 630 | The second element gives the position of the listbox element just after |
| 631 | the last one in the window, relative to the listbox as a whole. |
| 632 | These are the same values passed to scrollbars via the \fB\-yscrollcommand\fR |
| 633 | option. |
| 634 | .TP |
| 635 | \fIpathName \fByview\fR \fIindex\fR |
| 636 | Adjusts the view in the window so that the element given by |
| 637 | \fIindex\fR is displayed at the top of the window. |
| 638 | .TP |
| 639 | \fIpathName \fByview moveto\fI fraction\fR |
| 640 | Adjusts the view in the window so that the element given by \fIfraction\fR |
| 641 | appears at the top of the window. |
| 642 | \fIFraction\fR is a fraction between 0 and 1; 0 indicates the first |
| 643 | element in the listbox, 0.33 indicates the element one-third the |
| 644 | way through the listbox, and so on. |
| 645 | .TP |
| 646 | \fIpathName \fByview scroll \fInumber what\fR |
| 647 | This command adjusts the view in the window up or down according to |
| 648 | \fInumber\fR and \fIwhat\fR. |
| 649 | \fINumber\fR must be an integer. |
| 650 | \fIWhat\fR must be either \fBunits\fR or \fBpages\fR. |
| 651 | If \fIwhat\fR is \fBunits\fR, the view adjusts up or down by |
| 652 | \fInumber\fR lines; if it is \fBpages\fR then |
| 653 | the view adjusts by \fInumber\fR screenfuls. |
| 654 | If \fInumber\fR is negative then earlier elements |
| 655 | become visible; if it is positive then later elements |
| 656 | become visible. |
| 657 | .RE |
| 658 | |
| 659 | .SH "DEFAULT BINDINGS" |
| 660 | .PP |
| 661 | Tk automatically creates class bindings for listboxes that give them |
| 662 | Motif-like behavior. Much of the behavior of a listbox is determined |
| 663 | by its \fBselectMode\fR option, which selects one of four ways |
| 664 | of dealing with the selection. |
| 665 | .PP |
| 666 | If the selection mode is \fBsingle\fR or \fBbrowse\fR, at most one |
| 667 | element can be selected in the listbox at once. |
| 668 | In both modes, clicking button 1 on an element selects |
| 669 | it and deselects any other selected item. |
| 670 | In \fBbrowse\fR mode it is also possible to drag the selection |
| 671 | with button 1. |
| 672 | .PP |
| 673 | If the selection mode is \fBmultiple\fR or \fBextended\fR, |
| 674 | any number of elements may be selected at once, including discontiguous |
| 675 | ranges. In \fBmultiple\fR mode, clicking button 1 on an element |
| 676 | toggles its selection state without affecting any other elements. |
| 677 | In \fBextended\fR mode, pressing button 1 on an element selects |
| 678 | it, deselects everything else, and sets the anchor to the element |
| 679 | under the mouse; dragging the mouse with button 1 |
| 680 | down extends the selection to include all the elements between |
| 681 | the anchor and the element under the mouse, inclusive. |
| 682 | .PP |
| 683 | Most people will probably want to use \fBbrowse\fR mode for |
| 684 | single selections and \fBextended\fR mode for multiple selections; |
| 685 | the other modes appear to be useful only in special situations. |
| 686 | .PP |
| 687 | Any time the selection changes in the listbox, the virtual event |
| 688 | \fB<<ListboxSelect>>\fR will be generated. It is easiest to bind |
| 689 | to this event to be made aware of any changes to listbox selection. |
| 690 | .PP |
| 691 | In addition to the above behavior, the following additional behavior |
| 692 | is defined by the default bindings: |
| 693 | .IP [1] |
| 694 | In \fBextended\fR mode, the selected range can be adjusted by pressing |
| 695 | button 1 with the Shift key down: this modifies the selection to |
| 696 | consist of the elements between the anchor and the element under |
| 697 | the mouse, inclusive. |
| 698 | The un-anchored end of this new selection can also be dragged with |
| 699 | the button down. |
| 700 | .IP [2] |
| 701 | In \fBextended\fR mode, pressing button 1 with the Control key down |
| 702 | starts a toggle operation: the anchor is set to the element under |
| 703 | the mouse, and its selection state is reversed. The selection state |
| 704 | of other elements isn't changed. |
| 705 | If the mouse is dragged with button 1 down, then the selection state |
| 706 | of all elements between the anchor and the element under the mouse |
| 707 | is set to match that of the anchor element; the selection state of |
| 708 | all other elements remains what it was before the toggle operation |
| 709 | began. |
| 710 | .IP [3] |
| 711 | If the mouse leaves the listbox window with button 1 down, the window |
| 712 | scrolls away from the mouse, making information visible that used |
| 713 | to be off-screen on the side of the mouse. |
| 714 | The scrolling continues until the mouse re-enters the window, the |
| 715 | button is released, or the end of the listbox is reached. |
| 716 | .IP [4] |
| 717 | Mouse button 2 may be used for scanning. |
| 718 | If it is pressed and dragged over the listbox, the contents of |
| 719 | the listbox drag at high speed in the direction the mouse moves. |
| 720 | .IP [5] |
| 721 | If the Up or Down key is pressed, the location cursor (active |
| 722 | element) moves up or down one element. |
| 723 | If the selection mode is \fBbrowse\fR or \fBextended\fR then the |
| 724 | new active element is also selected and all other elements are |
| 725 | deselected. |
| 726 | In \fBextended\fR mode the new active element becomes the |
| 727 | selection anchor. |
| 728 | .IP [6] |
| 729 | In \fBextended\fR mode, Shift-Up and Shift-Down move the location |
| 730 | cursor (active element) up or down one element and also extend |
| 731 | the selection to that element in a fashion similar to dragging |
| 732 | with mouse button 1. |
| 733 | .IP [7] |
| 734 | The Left and Right keys scroll the listbox view left and right |
| 735 | by the width of the character \fB0\fR. |
| 736 | Control-Left and Control-Right scroll the listbox view left and |
| 737 | right by the width of the window. |
| 738 | Control-Prior and Control-Next also scroll left and right by |
| 739 | the width of the window. |
| 740 | .IP [8] |
| 741 | The Prior and Next keys scroll the listbox view up and down |
| 742 | by one page (the height of the window). |
| 743 | .IP [9] |
| 744 | The Home and End keys scroll the listbox horizontally to |
| 745 | the left and right edges, respectively. |
| 746 | .IP [10] |
| 747 | Control-Home sets the location cursor to the first element in |
| 748 | the listbox, selects that element, and deselects everything else |
| 749 | in the listbox. |
| 750 | .IP [11] |
| 751 | Control-End sets the location cursor to the last element in |
| 752 | the listbox, selects that element, and deselects everything else |
| 753 | in the listbox. |
| 754 | .IP [12] |
| 755 | In \fBextended\fR mode, Control-Shift-Home extends the selection |
| 756 | to the first element in the listbox and Control-Shift-End extends |
| 757 | the selection to the last element. |
| 758 | .IP [13] |
| 759 | In \fBmultiple\fR mode, Control-Shift-Home moves the location cursor |
| 760 | to the first element in the listbox and Control-Shift-End moves |
| 761 | the location cursor to the last element. |
| 762 | .IP [14] |
| 763 | The space and Select keys make a selection at the location cursor |
| 764 | (active element) just as if mouse button 1 had been pressed over |
| 765 | this element. |
| 766 | .IP [15] |
| 767 | In \fBextended\fR mode, Control-Shift-space and Shift-Select |
| 768 | extend the selection to the active element just as if button 1 |
| 769 | had been pressed with the Shift key down. |
| 770 | .IP [16] |
| 771 | In \fBextended\fR mode, the Escape key cancels the most recent |
| 772 | selection and restores all the elements in the selected range |
| 773 | to their previous selection state. |
| 774 | .IP [17] |
| 775 | Control-slash selects everything in the widget, except in |
| 776 | \fBsingle\fR and \fBbrowse\fR modes, in which case it selects |
| 777 | the active element and deselects everything else. |
| 778 | .IP [18] |
| 779 | Control-backslash deselects everything in the widget, except in |
| 780 | \fBbrowse\fR mode where it has no effect. |
| 781 | .IP [19] |
| 782 | The F16 key (labelled Copy on many Sun workstations) or Meta-w |
| 783 | copies the selection in the widget to the clipboard, if there is |
| 784 | a selection. |
| 785 | |
| 786 | .PP |
| 787 | The behavior of listboxes can be changed by defining new bindings for |
| 788 | individual widgets or by redefining the class bindings. |
| 789 | |
| 790 | .SH KEYWORDS |
| 791 | listbox, widget |