home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / tcl / 2450 < prev    next >
Encoding:
Internet Message Format  |  1993-01-22  |  1.2 KB

  1. Path: sparky!uunet!gatech!destroyer!news.itd.umich.edu!spencer
  2. From: spencer@med.umich.edu (Spencer W. Thomas)
  3. Newsgroups: comp.lang.tcl
  4. Subject: Re: Can windows be dragged on a canvas?
  5. Date: 22 Jan 93 10:53:20
  6. Organization: University of Michigan HSITN
  7. Lines: 19
  8. Message-ID: <SPENCER.93Jan22105320@guraldi.med.umich.edu>
  9. References: <mathew.727663312@henry>
  10. NNTP-Posting-Host: guraldi.itn.med.umich.edu
  11. In-reply-to: mathew@elroy.Jpl.Nasa.Gov's message of 22 Jan 93 00:41:52 GMT
  12.  
  13. I've done this.  You have to make the bindings to the window, not to
  14. the canvas:
  15.  
  16.     # Bind the actions ($f is the window name, $theCanvas is the
  17.     # canvas name).
  18.     bind $f <B3-Motion> "itemDrag $theCanvas \
  19.                     \[expr %x+\[winfo x $f]]\
  20.                     \[expr %y+\[winfo y $f]] $field";
  21.     bind $f <3> "itemStartDrag $theCanvas \[expr %x+\[winfo x $f]]\
  22.                     \[expr %y+\[winfo y $f]]";
  23.  
  24. The trick is that the %x and %y are relative to the window origin, so
  25. you have to add the position of the window relative to the canvas
  26. origin to reposition them.
  27.  
  28. --
  29. =Spencer W. Thomas         |  Info Tech and Networking, B1911 CFOB, 0704
  30.    "Genome Informatician"    |  Univ of Michigan, Ann Arbor, MI 48109
  31. Spencer.W.Thomas@med.umich.edu    |  313-747-2778, FAX 313-764-4133
  32.