The following illustrates the “drop” side of a Drag&Drop Copy operation between two TreeView objects (see the drag( ) example). The Target’s onDrop expects cType to contain the class name “TreeView”, and cName to contain the name of a text file produced by the Source TreeView’s streamChildren( ) method. If the parameters are correct, the event calls loadChildren( ) to repopulate the Target TreeView from the text file.

If the drop fails and there is an onLeftMouseUp event handler, it is explicitly called.

function TREEVIEW1_onDrop(nLeft, nTop, cType, cName)

  local lReturn

  lReturn = false             // Initialize return value

  if cType == this.className        // Validate first parameter

    if file( cName )           // Validate second parameter

      try                // Trap potential errors

        this.loadChildren( cName )     // Process

        delete file (cName)        // Clean up

        lReturn = true          // Return success

      catch ( Exception e )

        msgBox( e.message, "Copy failed" ) // Some error, no drop

      endTry

    endIf

  endIf

  if not lReturn

    if type( “this.onLeftMouseUp“ ) == “FP” // Test for mouse Up event handler

      this.onLeftMouseUp( )         // “Fire” if present

    endIf

  endIf

  return lReturn