home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!paladin.american.edu!howland.reston.ans.net!usc!elroy.jpl.nasa.gov!henry!mathew
- From: mathew@elroy.Jpl.Nasa.Gov (Mathew Yeates)
- Newsgroups: comp.lang.tcl
- Subject: Re: Can windows be dragged on a canvas?
- Date: 22 Jan 93 19:09:04 GMT
- Organization: Image Analysis Systems Group, JPL
- Lines: 54
- Message-ID: <mathew.727729744@henry>
- References: <mathew.727663312@henry> <SPENCER.93Jan22105320@guraldi.med.umich.edu>
- NNTP-Posting-Host: henry.jpl.nasa.gov
-
- spencer@med.umich.edu (Spencer W. Thomas) writes:
-
- >I've done this. You have to make the bindings to the window, not to
- >the canvas:
-
- > # Bind the actions ($f is the window name, $theCanvas is the
- > # canvas name).
- > bind $f <B3-Motion> "itemDrag $theCanvas \
- > \[expr %x+\[winfo x $f]]\
- > \[expr %y+\[winfo y $f]] $field";
- > bind $f <3> "itemStartDrag $theCanvas \[expr %x+\[winfo x $f]]\
- > \[expr %y+\[winfo y $f]]";
-
- Any idea why the following doesnt work? Source from within wish
-
- ------------------------------------------------------------------
-
- canvas .canvas -scrollregion {0 0 800 400} -width 800 -height 400
- frame .canvas.frame
- text .canvas.frame.photo -background black
- pack append .canvas.frame .canvas.frame.photo {top}
- .canvas create window 0 0 -window .canvas.frame -anchor nw -tags canvasitem
- pack append . .canvas {top}
-
- bind .canvas.frame.photo <1> "itemStartDrag .canvas \
- \[expr %x+\[winfo x .canvas.frame.photo]]\
- \[expr %y+\[winfo y .canvas.frame.photo]]";
-
- bind .canvas.frame.photo <B1-Motion> "itemDrag .canvas \
- \[expr %x+\[winfo x .canvas.frame.photo]]\
- \[expr %y+\[winfo y .canvas.frame.photo]]";
-
- proc itemStartDrag {c x y} {
- global lastX lastY
- set lastX [$c canvasx $x]
- set lastY [$c canvasy $y]
- puts stdout "start _[$c type current]_ $lastX $lastY"
- }
- proc itemDrag {c x y} {
- global lastX lastY
- set x [$c canvasx $x]
- set y [$c canvasy $y]
- $c move current [expr $x-$lastX] [expr $y-$lastY]
- puts stdout "[expr $x-$lastX] [expr $y-$lastY]"
- set lastX $x
- set lastY $y
- }
- --------------------------------------------------------
- if "current: in itemDrag is replaced by the tag "canvasitem" then
- the text window does, indeed, drag. But not correctly. It appears
- to lag behind the cursor. What am I doing wrong?
-
-
- Mathew Yeates
-