I'm trying to drag and drop from one canvas to another, but I'm having a few problems...
1. When you release the mouse button, the EVENT_MOUSEUP EventSource is the original canvas. (as expected, but it would have been nice anyway)
2. When you click and drag, it seems to ignor all other events apart from the ones from the original canvas, until you release the mouse button again, so I can't use EVENT_MOUSEENTER/MOUSELEAVE to catch it myself.
Simple tester...
Any ideas how to do it?
*EDIT* BTW going to work now, so wont be around for about 12hrs :(
1. When you release the mouse button, the EVENT_MOUSEUP EventSource is the original canvas. (as expected, but it would have been nice anyway)
2. When you click and drag, it seems to ignor all other events apart from the ones from the original canvas, until you release the mouse button again, so I can't use EVENT_MOUSEENTER/MOUSELEAVE to catch it myself.
Simple tester...
Strict Type TApplet Field window:TGadget Field canvas1:TGadget Field canvas2:TGadget Field Grabbing:Int ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Method New() window = CreateWindow("Test",20,20,512,512) Local w = ClientWidth(window) Local h = ClientHeight(window) canvas1 = CreateCanvas(0,0,(w/2)-20,h,window,PANEL_BORDER) canvas1.SetLayout 1,0,1,1 canvas2 = CreateCanvas((w/2)+20,0,(w/2)-20,h,window,PANEL_BORDER) canvas2.SetLayout 0,1,1,1 AddHook EmitEventHook,eventhook,Self End Method ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Function eventhook:Object(id,data:Object,context:Object) TApplet(context).OnEvent TEvent(data) Return data End Function Method OnEvent(event:TEvent) Select event.id Case EVENT_WINDOWCLOSE ; End Case EVENT_GADGETPAINT Select Event.Source Case Canvas1 ; Render1 Case Canvas2 ; Render2 EndSelect Case EVENT_MOUSEDOWN Select Event.Source Case Canvas1 ; Print "Grab from canvas1" Grabbing = True ; SetPointer(POINTER_HAND) Case Canvas2 ; Print "Grab from canvas2" Grabbing = True ; SetPointer(POINTER_HAND) EndSelect Case EVENT_MOUSEUP If Grabbing = True SetPointer(POINTER_DEFAULT) ; Grabbing = False Select Event.Source Case Canvas1 ; Print "Drop in canvas1" Case Canvas2 ; Print "Drop in canvas2" EndSelect EndIf Case EVENT_MOUSEENTER Select Event.Source Case Canvas1 ; Print "Enter canvas1" Case Canvas2 ; Print "Enter canvas2" EndSelect Case EVENT_MOUSELEAVE Select Event.Source Case Canvas1 ; Print "Leave canvas1" Case Canvas2 ; Print "Leave canvas2" EndSelect End Select End Method ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Method Render1() SetGraphics CanvasGraphics(canvas1) SetViewport 0,0,GraphicsWidth(),GraphicsHeight() SetClsColor 0,0,0 ; Cls DrawText "Canvas1",5,5 Flip End Method Method Render2() SetGraphics CanvasGraphics(canvas2) SetViewport 0,0,GraphicsWidth(),GraphicsHeight() SetClsColor 0,0,150 ; Cls DrawText "Canvas2",5,5 Flip End Method ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - End Type Local applet:TApplet = New TApplet While True WaitEvent Wend
Any ideas how to do it?
*EDIT* BTW going to work now, so wont be around for about 12hrs :(