How do you get the dragOver event to fire in a rectControl (e.g. containerControl)?
I can correctly make a dragItem and can see the graphic being dragged over the rectControl but dragOver does not fire.
I have turned on self.acceptRawDataDrop("???") in the receiving containerControl constructor.
I have splaced some rawData("???") in the dragItem.
I have returned false on dragEnter.
What other attributes or properties need to be in place to make it work?
The believe the Container Control won’t have the DragOver event but the Control that’s on the container will. Containers are ‘special’ and under the covers they are really a Window.
So, try putting a canvas in the Container put the Drag events into that.
Bob, thanks for the reply.
As the containerControl has all the Drag events listed(DragOver, DragEnter, DragExit, Drop) I thought it should work.
However, I tried your suggestion of using a canvas control on the CC, but still no joy, none of the events fire.
Can you post some code or even better make an example project? I’ve used DragOver for a Groupbox and a Listbox and both work fine.
In the Open event of the canvas I changed your code to me.AcceptTextDrop and it worked as expected.
Thanks, I now have it working.
Lessons learned (that I can’t see clearly in the manual).
- As you stated, Drag & Drop events don’t seem to fire in the ContainerControl (despite being available) - feedback already has this as 16577 on 4th April 2011.
- Drag & Drop events do fire in the Canvas control however:
2.1 The command self.acceptRawDataDrop(UTI) - the UTI needs to be of the form “fileType.dataType” - where fileType and dataType can be anything you want if keeping within the app, or must match the file UTI for dropping files in from outside.
2.2 The dragItem.Data(UTI) and dragItem.rawDataAvailable(UTI) UTI’s must match that in the original dragItem.rawData(UTI) = string.
2.3 MouseDown needs to return True to allow the MouseDrag to fire.
2.4 When MouseUp fires, it fires in the object where the drag started - not in the object where the drag finishes.
2.5 When DropObject fires, it fires in the object where the drag finishes.