home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / tcl / tk3.3b1 / doc / listbox.n < prev    next >
Encoding:
Text File  |  1993-04-15  |  9.6 KB  |  249 lines

  1. '\"
  2. '\" Copyright (c) 1990 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/wish/man/RCS/listbox.n,v 1.15 93/04/15 08:26:00 ouster Exp $ SPRITE (Berkeley)
  22. '/" 
  23. .so man.macros
  24. .HS listbox tk
  25. .BS
  26. '\" Note:  do not modify the .SH NAME line immediately below!
  27. .SH NAME
  28. listbox \- Create and manipulate listbox widgets
  29. .SH SYNOPSIS
  30. \fBlistbox\fI \fIpathName \fR?\fIoptions\fR?
  31. .SH "STANDARD OPTIONS"
  32. .LP
  33. .nf
  34. .ta 4c 8c 12c
  35. .VS
  36. \fBbackground\fR    \fBforeground\fR    \fBselectBackground\fR    \fBxScrollCommand\fR
  37. \fBborderWidth\fR    \fBfont\fR    \fBselectBorderWidth\fR    \fByScrollCommand\fR
  38. \fBcursor\fR    \fBgeometry\fR    \fBselectForeground\fR
  39. \fBexportSelection\fR    \fBrelief\fR    \fBsetGrid\fR
  40. .VE
  41. .fi
  42. .LP
  43. See the ``options'' manual entry for details on the standard options.
  44. .SH "WIDGET-SPECIFIC OPTIONS"
  45. .ta 4c
  46. .LP
  47. None.
  48. .BE
  49.  
  50. .SH DESCRIPTION
  51. .PP
  52. The \fBlistbox\fR command creates a new window (given by the
  53. \fIpathName\fR argument) and makes it into a listbox widget.
  54. Additional
  55. options, described above, may be specified on the command line
  56. or in the option database
  57. to configure aspects of the listbox such as its colors, font,
  58. text, and relief.  The \fBlistbox\fR command returns its
  59. \fIpathName\fR argument.  At the time this command is invoked,
  60. there must not exist a window named \fIpathName\fR, but
  61. \fIpathName\fR's parent must exist.
  62. .PP
  63. A listbox is a widget that displays a list of strings, one per line.
  64. When first created, a new listbox has no elements in its list.
  65. Elements may be added or deleted using widget commands described
  66. below.  In addition, one or more elements may be selected as described
  67. below.
  68. .VS
  69. If a listbox is exporting its selection (see \fBexportSelection\fR
  70. option), then it will observe the standard X11 protocols
  71. .VE
  72. for handling the selection;  listbox selections are available
  73. as type \fBSTRING\fR, consisting of a Tcl list with one entry
  74. for each selected element.
  75. .PP
  76. For large lists only a subset of the list elements will be
  77. displayed in the listbox window at once;  commands described below
  78. may be used to change the view in the window.  Listboxes allow
  79. .VS
  80. scrolling in both directions using the standard \fBxScrollCommand\fR
  81. and \fByScrollCommand\fR options.
  82. .VE
  83. They also support scanning, as described below.
  84.  
  85. .SH "WIDGET COMMAND"
  86. .PP
  87. The \fBlistbox\fR command creates a new Tcl command whose
  88. name is \fIpathName\fR.  This
  89. command may be used to invoke various
  90. operations on the widget.  It has the following general form:
  91. .DS C
  92. \fIpathName option \fR?\fIarg arg ...\fR?
  93. .DE
  94. \fIOption\fR and the \fIarg\fRs
  95. determine the exact behavior of the command.  The following
  96. commands are possible for listbox widgets:
  97. .TP
  98. \fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
  99. Query or modify the configuration options of the widget.
  100. If no \fIoption\fR is specified, returns a list describing all of
  101. the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for
  102. information on the format of this list).  If \fIoption\fR is specified
  103. with no \fIvalue\fR, then the command returns a list describing the
  104. one named option (this list will be identical to the corresponding
  105. sublist of the value returned if no \fIoption\fR is specified).  If
  106. one or more \fIoption\-value\fR pairs are specified, then the command
  107. modifies the given widget option(s) to have the given value(s);  in
  108. this case the command returns an empty string.
  109. \fIOption\fR may have any of the values accepted by the \fBlistbox\fR
  110. command.
  111. .TP
  112. \fIpathName \fBcurselection\fR
  113. .VS
  114. Returns a list containing the indices of
  115. all of the elements in the listbox that are currently selected.
  116. If there are no elements selected in the listbox then an empty
  117. string is returned.
  118. .VE
  119. .TP
  120. \fIpathName \fBdelete \fIfirst \fR?\fIlast\fR?
  121. Delete one or more elements of the listbox.  \fIFirst\fR and \fIlast\fR
  122. give the integer indices of the first and last elements in the range
  123. to be deleted.  If \fIlast\fR isn't specified it defaults to
  124. \fIfirst\fR, i.e. a single element is deleted.  An index of
  125. \fB0\fR corresponds to the first element in the listbox.  Either
  126. \fIfirst\fR or \fIlast\fR may be specified as \fBend\fR, in which
  127. case it refers to the last element of the listbox.  This command
  128. returns an empty string
  129. .TP
  130. \fIpathName \fBget \fIindex\fR
  131. Return the contents of the listbox element indicated by \fIindex\fR.
  132. \fIIndex\fR must be a non-negative integer (0 corresponds to
  133. the first element in the listbox), or it may also be specified as
  134. \fBend\fR to indicate the last element in the listbox.
  135. .TP
  136. \fIpathName \fBinsert \fIindex \fR?\fIelement element ...\fR?
  137. Insert zero or more new elements in the list just before the
  138. element given by \fIindex\fR.  If \fIindex\fR is specified as
  139. \fBend\fR then the new elements are added to the end of the
  140. list.  Returns an empty string.
  141. .TP
  142. \fIpathName \fBnearest \fIy\fR
  143. Given a y-coordinate within the listbox window, this command returns
  144. the index of the (visible) listbox element nearest to that y-coordinate.
  145. .TP
  146. \fIpathName \fBscan\fR \fIoption args\fR
  147. This command is used to implement scanning on listboxes.  It has
  148. two forms, depending on \fIoption\fR:
  149. .RS
  150. .TP
  151. \fIpathName \fBscan mark \fIx y\fR
  152. .VS
  153. Records \fIx\fR and \fIy\fR and the current view in the listbox
  154. window;  used in conjunction with later \fBscan dragto\fR commands.
  155. Typically this command is associated with a mouse button press in
  156. the widget.  It returns an empty string.
  157. .TP
  158. \fIpathName \fBscan dragto \fIx y\fR.
  159. This command computes the difference between its \fIx\fR and \fIy\fR
  160. arguments and the \fIx\fR and \fIy\fR arguments to the last
  161. \fBscan mark\fR command for the widget.
  162. It then adjusts the view by 10 times the
  163. difference in coordinates.  This command is typically associated
  164. .VE
  165. with mouse motion events in the widget, to produce the effect of
  166. dragging the list at high speed through the window.  The return
  167. value is an empty string.
  168. .RE
  169. .TP
  170. \fIpathName \fBselect \fIoption arg\fR
  171. This command is used to adjust the selection within a listbox.  It
  172. has several forms, depending on \fIoption\fR.  In all of the forms
  173. the index \fBend\fR refers to the last element in the listbox.
  174. .RS
  175. .TP
  176. \fIpathName \fBselect adjust \fIindex\fR
  177. Locate the end of the selection nearest to the element given by
  178. \fIindex\fR, and adjust that end of the selection to be at \fIindex\fR
  179. (i.e including but not going beyond \fIindex\fR).  The other
  180. end of the selection is made the anchor point for future
  181. \fBselect to\fR commands.  If the selection
  182. isn't currently in the listbox, then this command is identical to
  183. the \fBselect from\fR widget command.
  184. Returns an empty string.
  185. .TP
  186. \fIpathName \fBselect clear\fR
  187. .VS
  188. If the selection is in this listbox then it is cleared so that
  189. none of the listbox's elements are selected anymore.
  190. .VE
  191. .TP
  192. \fIpathName \fBselect from \fIindex\fR
  193. Set the selection to consist of element \fIindex\fR, and make
  194. \fIindex\fR the anchor point for future \fBselect to\fR widget
  195. commands.  Returns an empty string.
  196. .TP
  197. \fIpathName \fBselect to \fIindex\fR
  198. Set the selection to consist of the elements from the anchor
  199. point to element \fIindex\fR, inclusive.  The anchor point is
  200. determined by the most recent \fBselect from\fR or \fBselect adjust\fR
  201. command in this widget.  If the selection isn't in this widget,
  202. this command is identical to \fBselect from\fR.
  203. Returns an empty string.
  204. .RE
  205. .TP
  206. \fIpathName \fBsize\fR
  207. Returns a decimal string indicating the total number of elements
  208. in the listbox.
  209. .TP
  210. \fIpathName \fBxview \fIindex\fR
  211. .VS
  212. Adjust the view in the listbox so that character position \fIindex\fR
  213. is displayed at the left edge of the widget.
  214. Returns an empty string.
  215. .TP
  216. \fIpathName \fByview \fIindex\fR
  217. Adjust the view in the listbox so that element \fIindex\fR is
  218. displayed at the top of the widget.
  219. If \fIindex\fR is specified as \fBend\fR it indicates the last
  220. element of the listbox.  Returns an empty string.
  221. .VE
  222.  
  223. .SH "DEFAULT BINDINGS"
  224. .PP
  225. .VS
  226. Tk automatically creates class bindings for listboxes that give them
  227. the following default behavior:
  228. .IP [1]
  229. When button 1 is pressed over a listbox, the element underneath the
  230. mouse cursor is selected.  The mouse can be dragged to select a
  231. range of elements.
  232. .IP [2]
  233. The ends of the selection can be adjusted by dragging with mouse
  234. button 1 while the shift key is down;  this will adjust the end
  235. of the selection that was nearest to the mouse cursor when button
  236. 1 was pressed.
  237. .IP [3]
  238. The view in the listbox can be adjusted by dragging with mouse button 2.
  239. .PP
  240. The behavior of listboxes can be changed by defining new bindings for
  241. individual widgets or by redefining the class bindings.
  242. In addition, the procedure \fBtk_listboxSingleSelect\fR may be
  243. invoked to change listbox behavior so that only a single element
  244. may be selected at once.
  245. .VE
  246.  
  247. .SH KEYWORDS
  248. listbox, widget
  249.