PA_GetDragAndDropInfo


typedef struct PA_DragAndDropInfo { char fReserved1[10]; long fToArrayIndice; // indice of element when destination is an array long fReserved2[2]; long fFromArrayIndice; // indice of element when source is an array short fFromProcess; short fFromWhereV; // where user clicks at first short fFromWhereH; short fToWhereV; // where user release mouse button short fToWhereH; long fReserved3; char fVariableName[32]; // empty string or variable name if user drags a variable char fInterProcess; short fField; short fTable; // zero or table name if user drags a field from a table PA_DragContextRef fDragContext; // the current drag and drop context (new v11 field) } PA_DragAndDropInfo;

version 2003


PA_GetDragAndDropInfo (params) → PA_DragAndDropInfo

Parameter Type Description
params PA_PluginParameters Parameters received in PluginMain
Function result PA_DragAndDropInfo Information on the Drag/Droppped object

Description

The routine PA_GetDragAndDropInfo returns a structure of type PA_DragAndDropInfo , which contains various information on the object being drag/dropped onto the area. This routine must be called when PA_GetAreaEvent returns eAE_Drop or eAE_AllowDrop . If it is called at another time, it does nothing, PA_GetLastError returns eER_BadEventCall , and, most importantly, the returned structure can contain garbage (the returned PA_DragAndDropInfo is not initialized to null values).

When the event is eAE_AllowDrop , the area can check the kind of object being dropped, and then allow or disallow the drop by calling PA_AllowDrop .

If the drag/drop is allowed and the user dropped the object, call PA_GetDragAndDropInfo again to retrieve its value.

The PA_DragAndDropInfo structure is defined in the "PublicTypes.h" header file, and this API contains its the main accessors ( PA_GetDragAndDropKind , PA_GetDragAndDropVariable , PA_GetDragAndDropTableField ).

typedef struct PA_DragAndDropInfo
{
   char   fReserved1[10];
   long   fToArrayIndice;   // index of element when destination is an array
   long   fReserved2[2];
   long   fFromArrayIndex;   // index of element when source is an array
   short   fFromProcess;
   short   fFromWhereV;   // where user clicks at first
   short   fFromWhereH;
   short   fToWhereV;      // where user release mouse button - _global_ coordinates
   short   fToWhereH;
   long   fReserved3;
   char   fVariableName[32];   // empty string or variable name if user drags a variable
   char   fInterProcess;
   short    fField;
   short   fTable;      // zero or table name if user drags a field from a table
} PA_DragAndDropInfo;

NOTE

The routines "Drag and Drop" are internal to 4th Dimension. The developer cannot use them with other applications.

NOTE

The coordinates included in the structure referring to the screen are global. The area must convert them ( ScreenToClient under Windows and GlobalToLocal under MacOS) if those coordinates are used by it later.

Examples

(1) See the sample in Drag and drop with a plug-in area.

(2) Allow drag and drop only if the object is a real array element.

   /* . . . assume we are dispatching a PA_AreaEvent . . . */
      case eAE_AllowDrop:
      {
         char   allow = 0;
         long   index;
      // get the drag-drop info
         PA_GetDragAndDropInfo   ddi = PA_GetDragDropInfo(params);
      // if the object is a variable...
         if( PA_GetDragAndDropKind(ddi) == eDK_DragVariable )
         {
      // ... of type array long integer...
            if( PA_GetVariableKind(PA_GetDragAndDropVariable(params, &index)) == eVK_ArrayLongint )
      // ... we accept it.
               allow = 1;
            
         }
         PA_AllowDrop(params, allow);
      }
         break;
 

(3) Returns the process number owning the object.

   long GetSourceProcessOfTheObject(PA_PluginParameters params)
   {
      PA_DragAndDropInfo   ddi = PA_GetDragAndDropInfo(params);
      if( PA_GetLastError() == eER_NoErr)
         return ddi.fFromProcess;
      else
         return 0L.
   }

See Also

Drag and drop with a plugin area , PA_AllowDrop , PA_CustomizeDragOver , PA_GetDragPositions .

Error Handling

Use PA_GetLastError to see if an error occurred ( eER_BadEventCall )