Please enable JavaScript to view this site.

ESL Documentation

Navigation: ESL Documentation > ESL Programmers Guide > Drag and Drop > Overview

Sequence of Events in a Drag Operation

Scroll Prev Top Next More

The sequence of steps in a drag and drop operation is as follows:

 

1.        The user presses the appropriate mouse button over an ESL object, and begins to move the mouse while holding down the button. At this point the on drag response is triggered for the ESL object.

 

2.        The drag does not start automatically. To initiate a drag, the program has to use the drag action statement inside an on drag response. The drag action statement specifies the data being dragged, the type of data being dragged, and an icon to display during the drag, as shown in the following code:

 

response to ReportIcon_IR

  on drag

drag "myreport.txt" type "Report"

          using icon "report.ico"

 

3.        As the user moves the mouse cursor over other ESL objects, the on dragover response is triggered. This response is where the potential target object determines if it understands the data being dragged. The response can use the dragtype built-in function to determine the type of the data (as specified in the drag action statement). You may also use the xcoord and ycoord functions to determine if a drop at the current position is allowed. If a drop is allowed, the allow drop action is executed, as shown in the following code:

 

response to PrinterIcon_IR

  on dragover

    if (dragtype = "Report") then

        allow drop

    end if

 

If the allow drop action is not executed, the mouse cursor automatically changes to indicate to the user that a drop is not allowed.

 

4.        The drag can terminate in one of three ways:

 

a.        If the user releases the mouse button over an ESL object that understands the data, an on drop response is triggered for that object. This response contains the code that performs the application function that is represented by the drag operation.

 

response to PrinterIcon_IR

 on drop

   if (dragtype = "Report") then

    copy dragdata to ReportName_SV

    call PrintReport( ReportName_SV )

   end if

 

b.        If the user presses the F1 key over an ESL object that understands the data, an on drophelp response is triggered for that object. This gives the application the chance to display context-sensitive help explaining what happens if the user drops at that point.

 

response to PrinterIcon_IR

  on drophelp

  if (dragtype = "Report") then

             copy "Drop Report" to HelpPanel_SV

  call HelpDisplayHelpPanel( HelpPanel_SV )

  end if

 

c.        If the user presses the Escape key or releases the mouse button over an ESL object that does not understand the data, the drag is canceled. No response is triggered in this case.