Drag from a Control

Greetings -

I have an application that could benefit from behaving a little like the Xojo IDE desktop. In particular, I would like to implement a “library” (a sidebar, as in the Xojo IDE) of functions that add symbols to a canvas in the same window AT RUN TIME. I have no problem with positioning the symbols in the canvas. Where I have a problem is getting symbols onto the canvas.

  1. I COULD write it so that clicking a “button” (that is a graphic symbol) in the Library pane pops one onto the canvas at some predefined location. The user would then drag it out of that spot to the desired place. It will work, but I consider it a bit ugly. On the other hand, it behaves very much like the “ObjectsInCanvas” Xojo example and should be straight forward to code.

  2. What I would LIKE the user to be able to do is drag the graphic (or a representation of the graphic such as an outline) from the graphic in the Library pane onto the canvas. Like we do in the Xojo IDE. But, I cannot find any examples or descriptions in the Tutorials or anything that makes any sense in the LR.

I THINK that i would need to use control.DragExit, but I don’t know what to specify as the arguments. The first argument is Object as DragItem. Do I simply specify a picture? But that does not sound right because a picture is not a DragItem object without doing something more. And, I don’t know which action to specify. Then, there is the question of what to do with it when it reaches the Canvas.

Can someone help me out a little here? I would really appreciate it.

Jim Wagner
Oregon Research Electronics

In the control you’re dragging from, in MouseDown, construct a DragItem using the picture. Then assign the picture to the dragitem’s Picture property. Call Drag.

In the control you’re dragging to, in Open, call AcceptPictureDrop. Implement DropObject.

Thanks, Tim -

It was the call for Drag and the AcceptPictureDrop in the target that I was missing.

Jim