home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / tcl / 1215 < prev    next >
Encoding:
Internet Message Format  |  1992-08-18  |  1.9 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!uakari.primate.wisc.edu!ames!agate!agate!adrianho
  2. From: adrianho@barkley.berkeley.edu (Adrian J Ho)
  3. Newsgroups: comp.lang.tcl
  4. Subject: Re: bind: How to select using Button-3
  5. Message-ID: <ADRIANHO.92Aug18074134@barkley.berkeley.edu>
  6. Date: 18 Aug 92 12:41:34 GMT
  7. References: <1992Aug18.123400.3968@gmd.de>
  8. Organization: University of California, Berkeley
  9. Lines: 29
  10. NNTP-Posting-Host: barkley.berkeley.edu
  11. In-reply-to: richard@borneo.gmd.de's message of 18 Aug 92 12:34:00 GMT
  12.  
  13. In article <1992Aug18.123400.3968@gmd.de> richard@borneo.gmd.de (Richard Czech) writes:
  14. >I have a Tcl/Tk application in which I want to have different bindings
  15. >for Button-1 and Button-3 in several listboxes as follows:
  16. >[...]
  17. >It works fine for Button-1, because the selection of elements in
  18. >listboxes is predefined for Button-1. [...] But how is this done?
  19.  
  20. In general, questions about default class bindings can be answered by
  21. looking at $tk_library/tk.tcl, in which all class bindings are found.
  22. (Larry, I think this little-known fact qualifies for the FAQ. 8-)
  23.  
  24. In the case of listboxes, there is no binding for <B1-ButtonRelease>,
  25. so you'll have to add that yourself, like this:
  26.  
  27. bind Listbox <B1-ButtonRelease> {echo foo [%W curselection]}
  28.  
  29. >Can I define the same functionality for Button-3 using the bind command?
  30.  
  31. Sure.
  32.  
  33. bind Listbox <3> {%W select from [%W nearest %y]}
  34. bind Listbox <B3-Motion> {%W select to [%W nearest %y]}
  35. bind Listbox <B3-ButtonRelease> {echo bar [%W curselection]}
  36. --
  37. -----------------------------------------------------------------------------
  38. Adrian Ho, He With The Embarrassingly *Dead* Passion ** Phone: (510) 642-5563
  39. System Manager, CFD Lab, ME Dept, UC Berkeley * adrianho@barkley.berkeley.edu
  40. Maintainer, Tcl/Tk Contrib Archive ---- barkley.berkeley.edu [128.32.142.237]
  41.   Send all Tcl/Tk Archive-related stuff to tcl-archive@barkley.berkeley.edu
  42.