Hello,
I have a project with two canvases of the same size (512x512), Canvas1
and Canvas2, which is also the control order. What I want to do is to
scroll an icon (picture) in Canvas2 over the background of Canvas1
(canvases overlap) in response to the user performing a MouseDrag. I
have already achieved this effect by simply using drawPicture in a
single canvas (as opposed to actual scrolling), but I am trying to use
the Canvas control's Scroll method for speed.
First, I draw to the backdrop of Canvas1 via newPicture and fillRect to
make some squares.
When I MouseDown in Canvas2, I drawPicture a small icon to its Graphics
property and remember the position relative to the canvas. When I
MouseDrag in Canvas2, I use me.scroll to scroll the icon.
When Canvas1 and Canvas2 are completely separated, the icon scrolls in
Canvas2 and the backdrop of Canvas1 remains fixed, as expected.
When I change the two canvases to overlap completely (by changing Left
and Top in Properties of Canvas2), both the icon of Canvas2 and the
backdrop of Canvas1 scroll, which is not desired.
When I change the two canvases to overlap partially, the icon scrolls
and the overlapped backdrop portion scrolls.
Can I overlap the canvases but have only the icon scroll? I had
thought that the "ScrollControls" parameter of the Canvas Scroll method
would stop other controls (such as Canvas1) from scrolling, but I have
not succeeded with this.
Details follow.
Canvas1 Open:
backgroundBoard = newPicture(512,512,16)
backgroundBoard.graphics.foreColor = ...
backgroundBoard.graphics.fillRect ...
me.backdrop = backgroundBoard
Canvas2 Open:
myPic = newPicture(64,64,16)
myPic.transparent = 1
myPic.graphics.drawPicture ...
Canvas2 MouseDown:
Dim g as graphics
lastX = x
lastY = y
g = me.graphics
g.drawPicture myPic,x,y
return true
Canvas2 MouseDrag:
Dim g as graphics
if x <> lastX or y <> lastY then
me.scroll x-lastX,y-lastY,0,0,512,512,false
lastX = x
lastY = y
end if
Environment: Mac OS 10.3.7, REALbasic 5.2.4.
Gary Kobliska
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|