Scrolling canvas by dragging objects within them 
Author Message
 Scrolling canvas by dragging objects within them

I have a scrollable canvas where I drag objects around.  I want
the canvas to scroll with the drag.  I'm familiar with the
scan mark and scan dragto command but I can't quite put everything
together to make this work.  What I need is a command that will
tell me the coordinate of all four corners of the canvas in
canvas coordinates so I can compare that to the mouse coordinates.
If the mouse is outside the canvas, I can use scan mark and scan
dragto to scroll the canvas.

Also, is there a simple binding for PageUp, PageDn, UpArrow,
and DownArrow to scroll a canvas also?

--
Regards,
Mark

---------------------------------------------------------------------------

Chrysalis Symbolic Design       | uunet:     ...!uunet!chrysalis!gillman
9430 Research Blvd.             | TEL:       (512) 343-3623
Echelon IV                      | FAX:       (512) 342-2270
Suite 400                       | PAGER:     (800) 580-6294
Austin, Texas 78759             |



Tue, 10 Aug 1999 03:00:00 GMT  
 Scrolling canvas by dragging objects within them

Quote:

> I have a scrollable canvas where I drag objects around.  I want
> the canvas to scroll with the drag.  I'm familiar with the
> scan mark and scan dragto command but I can't quite put everything
> together to make this work.  What I need is a command that will
> tell me the coordinate of all four corners of the canvas in
> canvas coordinates so I can compare that to the mouse coordinates.
> If the mouse is outside the canvas, I can use scan mark and scan
> dragto to scroll the canvas.

Here's a strategy....
Assuming that your canvas is bounded on three sides by known
widgets (e.g. scrollbar for x, scrollbar for y and menubar),
use the [winfo containing %X %Y] do determine what window your
in....and set the scroll direction appropriately.

Then call tkScrollByUnits .can.scrolly v 1 for example to
scroll the canvas down assuming your y scrollbar is called
.can.scrolly.  Do similarly for the other scenarios.  Of course,
this code would probably be placed in the B1-Motion binding
on the canvas.  If the cursor is back on the canvas, reset
the scroll direction to none.

I know it's not a explicit hint....but I've implemented what your
asking using this kind of technique.

Chris
(it's not present in the Mini-Impress Tclet though...hmmm...something
to add)

Quote:

> Also, is there a simple binding for PageUp, PageDn, UpArrow,
> and DownArrow to scroll a canvas also?

> --
> Regards,
> Mark

> ---------------------------------------------------------------------------

> Chrysalis Symbolic Design       | uunet:     ...!uunet!chrysalis!gillman
> 9430 Research Blvd.             | TEL:       (512) 343-3623
> Echelon IV                      | FAX:       (512) 342-2270
> Suite 400                       | PAGER:     (800) 580-6294
> Austin, Texas 78759             |

--
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=

North Texas Linux Users Group  \|/       "All of it."
Tcl Dallas                     /|\            "Call it CDE."
ACM                           //|\\ (test procedures for...you know...)


Tue, 10 Aug 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problem picking canvas objects in scrolled canvas

2. Tkinter Canvas & Fast Scrolling/Dragging

3. Tk Canvas and Fast Scrolling/Dragging

4. Canvas scroll while dragging item

5. Why won't my scrolling canvas scroll?

6. How to drag from one canvas and drop in the other canvas

7. scrolling text widgets inside a scrolling canvas

8. Two canvas scrolled simultaneously by the same scrollbar (an UNIQUE scrollbar and TWO or more canvas)

9. Problems with resizing canvas within a canvas.

10. canvas within canvas

11. .canvas canvas[x,y] + scrolling -> problems

12. ?: changing object apperance by dragging another object

 

 
Powered by phpBB® Forum Software