Drag and drop

It is possible use dragging to connect sources and targets. A source is a button that looks for special VBTs marked as targets. When the mouse button remains down and mouse is over a target, the source's hit method is called to see if the target is acceptable to the source. If so, the excited method of the target VBT is called to give provide feedback. When the mouse button is released or the mouse leaves the domain of the target, the target's normal method is called.

The program Source.m3 uses SourceVBT to place random numbers in one of two boxes. A random number appears in the top box. Pressing a mouse button in the top box and dragging the cursor to one of the two lower boxes causes the number to appear in the selected box. Then another random number appears in the top box.

The action is depicted in a series of four images:

In the first picture, the application has just started and has selected the first random number. In the next picture the user has dragged the number to the lower right box, and a new random number has been generated. The next number is dragged to the lower left box. In the fourth picture the number has been dragged again to the lower left.