User Tools

Site Tools


drag_and_drop_commands

CalendarSet Drag and Drop Commands


Drag and Drop

Drag and drop of events and banners onto days, events and banners is available from and to CalendarSet areas.


Overview

When an item is clicked and dragged, the cursor will change. 
If the drop is allowed, the cursor will have a plus symbol attached to it when it hovers over the “drop” area:

If the drop is not allowed by the destination object, you’ll see a “no entry” sign instead:

Dragging

You can allow events and banners to be dragged from a CalendarSet area and dropped to various destinations:

  • a day, an event or a banner in the same CalendarSet area

  • a day, an event or a banner in another CalendarSet area

  • any 4D droppable object
  • another application that accepts text

Dropping

You can also allow dropping onto days, events and / or banners in a CalendarSet area from various sources:

  • events and banners in the same CalendarSet area

  • events and banners in another CalendarSet area

  • rows, columns or cells in an AreaList Pro area
  • any 4D draggable object

  • text or other contents displayed in another application window
  • a document in a MacOS Finder or Windows Explorer window

Controlling the Drag and Drop

You can control each CalendarSet area's draggability and droppability:


  • if the area can be dragged from

  • if the area can be dropped to

  • which item types (days, events and/or banners) can be dropped to

  • which CalendarSet or AreaList Pro areas can be the source or destination
  • if external sources (non-CalendarSet/AreaList Pro objects) are allowed
  • whether an attempted a drop on the area is accepted or rejected
  • what happens after a drop

Configuring Drag and Drop

You must configure CalendarSet to allow dragging out of and into a CalendarSet area. Commands provide the control necessary to allow or disallow dragging within an area, between two or more areas or from non-plugin objects.

You can allow dropping onto days, events and/or banners. For drags that originate from other sources, the dropping onto days could be conceived as the creation of a new event. Dropping onto events or banners could be thought of as “linking” of some outside information to the event (such as linking a contact to an event).

To allow dragging out of CalendarSet, you must pass an “access code” for the area that is to be dragged from. You must specify at least one code to enable dragging, using CS_SetDrgSrc. Up to ten codes can be passed. Allowing many codes provides for more flexibility in enabling and disabling dragging between various areas. This will be explained in more depth below.

In order to allow dropping into CalendarSet, you must pass an “access code” for each type of item (days, events and / or banners) that can be the destination of a drop. You must specify at least one code to enable dropping, using CS_SetDrgDst. As with CS_SetDrgSrc, up to ten codes can be passed for flexibility reasons.


CalendarSet DataType

CalendarSet supports one source data type and three destination data types:

  • dragging events and banners

  • dropping to days

  • dropping to events
  • dropping to banners


This DataType parameter is used in the commands CS_SetDrgSrc, CS_SetDrgDst, and CS_GetDrgDstTyp.

These are the possible values:

Source or destination Value Constant
Day (destination) 1 CS_DragDestination_Day
Event (destination) 2 CS_DragDestination_Event
Banner (destination) 3 CS_DragDestination_Banner
Event or banner (source) 2 CS_DragSource_EventBanner

Use CS_GetDrgSrcEvt to determine whether an event or banner was dragged, and which event or banner it was after a drop has completed


What are access “codes”?

The access codes that are passed in CS_SetDrgSrc. and CS_SetDrgDst. are used to enable dragging between specific drag partners. These drag partners can be the same CalendarSet area, different CalendarSet areas, AreaList Pro plugin areas, text selections from 4D or other applications and external documents.

  • Setting at least one source access code to an area will make it draggable.

  • Setting at least one destination access code to an area will make it droppable (on the specified object type).

Note: for compatibility reasons the CalendarSet area is draggable and droppable even if it is not set as draggable or droppable in the 4D layout's object properties.

Drag and drop between plugin areas

When dragging from and to CalendarSet or AreaList Pro areas (or within the same area) the source of the drag and the target of the drop are designated as drag and drop partners. You need to tell CalendarSet (and AreaList Pro if used) what these partnerships are, and to do this you create access codes.

An access code is simply a text code that you create. Let’s say you have a layout that contains two CalendarSet areas: Cal1 and Cal2, and you want to enable items to be dragged from Cal1 and dropped onto Cal2. You might decide on the access code “select”. To enable event and banner dragging you will need two lines of code:

CS_SetDrgSrc(Cal1;CS_DragSource_EventBanner;"select") 
CS_SetDrgDst(Cal2;CS_DragDestination_Day;"select") 

You can list up to 10 access codes for each source (events and banners) and destination (days, events or banners). For example, suppose you have four CalendarSet areas on a form: AreaA, AreaB, AreaC and AreaD. You want to allow drag and drop from AreaA to AreaB or AreaC, and from AreaD to AreaC but not AreaB:

1. Create two access codes: “dropB” and “dropC”.

2. Set the access codes for the four areas as follows:

CS_SetDrgSrc(AreaA;CS_DragSource_EventBanner;"dropB";"dropC") // drag to B and C 
CS_SetDrgSrc(AreaD;CS_DragSource_EventBanner;dropC") // drag to C 
CS_SetDrgDst(AreaB;CS_DragDestination_Day;"dropB") // accept drop to days from A 
CS_SetDrgDst(AreaC;CS_DragDestination_Day;"dropC") // accept drop to days from A & D 

Note: as opposed to AreaList Pro properties where all access codes are passed in the same string (list of codes separated by ‘|’), with CalendarSet each access code is a parameter by itself: “dropB”;“dropC”.

That’s all you need to do to enable basic drag and drop functionality between two areas with default settings.

When a drag and drop takes place, the drag sender’s plugin code communicates its access codes to the drop receiver’s plugin code. The drop receiver will compare the access codes of the sender to its own codes. If any of the codes match, the drop is allowed. This mechanism allows a number of combinations between several drag and drop partners.

Note: access codes are strictly compared, taking into account case and diacritics.

The following is an example of enabling the dragging and dropping of events within the same CalendarSet area by setting a unique identifier that only enables dragging within this area.

// enable drag events to days within this area

vSelfStr:="CalendarSetArea"+String(eCal) // only allows dragging and dropping within this area 
CS_SetDrgSrc(eCal;CS_DragSource_EventBanner;vSelfStr) // event or banner data type for source 
CS_SetDrgDst(eCal;CS_DragDestination_Day;vSelfStr) // day data type for destination 

Drag and drop with external objects

External objects are defined in this context as non CalendarSet (or AreaList Pro) plugin areas:


  • Dragging from and dropping to 4D fields, variables or any droppable/draggable object

  • Dragging from and dropping to 4D text selections (like a text variable content)

  • Dragging from and dropping to text selections in other applications (open windows from e.g. a text editor)
  • Dragging from external files (no dropping to)

Since external objects obviously don't support access codes they will be potential recipients of any drag from a draggable CalendarSet area, or source of any drop to a droppable CalendarSet area.

Any source access code will make a CalendarSet area draggable to external objects.

The “_external” special access code must be used as a destination access code in order to make a CalendarSet area droppable from external objects:

  •  “_external” can only be used as a destination access code and is the only way to make a CalendarSet area accept a drop from objects other that CalendarSet or AreaList Pro areas 

  •  “_external” as a destination access code means “drop onto this CalendarSet area from any external object”

We can modify the example above to allow dragging from an external object to area B: 


CS_SetDrgSrc(AreaA;CS_DragSource_EventBanner;"dropB";"dropC") // drag to B, C and external objects 
CS_SetDrgSrc(AreaD;CS_DragSource_EventBanner;dropC") // drag to C and external objects 
CS_SetDrgDst(AreaB;CS_DragDestination_Day;"dropB";"_external") // accept drop from A & external objects 
CS_SetDrgDst(AreaC;CS_DragDestination_Day;"dropC") // accept drop from A & D 


Using the callback method


You can fine-tune your control over the user's drag and drop from the callback method set by CS_SetCallback.

During a drag and drop, this method will be called under two circumstances: 


  •  When a drop is attempted from an external object, while the pointer is still hovering over the CalendarSet destination area: the $0 value returned by the callback will allow the subsequent drop action or not (as with setting access codes to control drag and drop between plugin areas): CS_Action_DragOver. 

  •  After a drop has been performed, whatever the source was (plugin area or external object): CS_Action_Drop. 


Note: the callback method will not be called with CS_Action_DragOver when the source of the drag and drop is a plugin area, where access codes are used instead to specifically allow drag and drop between areas.

When the drop is completed, the form method/CalendarSet area object (or callback method if previously set by CS_SetCallback.) is executed. You can then determine what the last user action was using CS_GetAction (form / object method) or $2 (callback method).


The event 4 (drag) is not reported if the drag ended as drop into the same CalendarSet area.

The source area's last action is 4 (drag), the destination area's last action is CS_Action_Drop.


Action 4 (drag) should no longer be used anyway. Use the CS_Action_Drop callback action instead, or the form / object method On Drop event. 


Note: the action reported by CS_GetAction will never be CS_Action_DragOver for an external object source, but the callback will receive this event in $2. See On drag over below

On drag over


The callback method is called with the CS_Action_DragOver action when an external object is dragged over the area. It is used to allow or reject the drop.

Note: never display a window in the callback while processing this CS_Action_DragOver action, including TRACE or ALERT: 4D would freeze (ACI0087433).

This method (actually a function in this case) receives two parameters, and must return a result:


  • $1 is the destination CalendarSet area reference.

  • $2 is the action code, in this case CS_Action_DragOver
  • $0 is expected by CalendarSet (only with this action), with either 0 (disallow drop) or 1 (allow drop).

Note: if no callback is set the drop from an external object will always be accepted (provided that “_external” is set as a destination access code for the area). Therefore the callback is the only way to disallow a drop from an external object on a droppable area.

The pointer shape will depend upon this result:

  • plus symbol if the drop is allowed:

  • “no entry” sign if the drop is non allowed:

Note: once an allowed destination has been rolled over, the cursor will stay as “+” even when you subsequently move to a place where the drop is not allowed: the drop will nevertheless be allowed and the On Drop form event will be triggered. This is due to a limitation of 4D, which does not call the plugin again to ask if the drop is allowed unless you leave the area and re-enter it again. In this case CS_GetDrgXXX will return zeros.

After the drop

When an event or banner is dropped onto a CalendarSet area, the following information is available to you:

  • Notification that a drop occurred

  • Which item was dragged and dropped (index in array) and what type (event or banner)

  • Where the event was dragged from (this area or another area, or another kind of object)
  • The type of data that was the recipient of the drop (day, event or banner)

  • If the destination type is a day, the date of that day

  • If the destination type is an event or banner, the event or banner index within its respective arrays

The processing of the drop event can either be handled in the callback with the CS_Action_Drop action or the form method / CalendarSet area object method with the On Drop event, which is always executed in the context of the destination area / process.The call sequence is:

1. Callback method with CS_Action_Drop in $2

2. Area object method with On Drop form event

3. Form method with On Drop form event

Note: when displaying CalendarSet in an external window there is no form / object method to execute, therefore the callback is the only way to control drag and drop in this context.

The callback method receives two parameters:


  • $1 is the destination CalendarSet area reference.
  • $2 is the action code, in this case CS_Action_Drop

You can determine which event or banner was dropped using CS_GetDrgSrcEvt.

To determine which object was the source of the drag, call CS_GetDrgSrcArea. This command returns the area reference (a long integer) and the process ID of the source area, whether it is the same CalendarSet area or another CalendarSet area, or an AreaList Pro area (the area reference will be negative in this case).

See also Receiving a drop from a non-CalendarSet Object below.


When dragging to/from another area or a 4D object, that object can either reside in the same window or on another window, which may require use of 4D’s process communication commands to take action on the drop.

Note: when dragging and dropping to or from other objects, CalendarSet is only providing a user interface to the drag, and notifying you, the developer, that the drop has occurred. You are responsible for manipulating any arrays or other data structures.

You must call CS_GetDrgDstTyp to determine if the destination of the drop was either a day or event.

  •  If the destination was a day, CS_GetDrgDstDay is used to determine the destination date. 

  •  If the destination was an event or banner, CS_GetDrgDstEvt is called to determine which event or banner was the destination. 


In the case when the sender and the receiver is the same CalendarSet area:

  •  If the source of the drag is an event and the destination is a day, then CalendarSet will automatically update the event date array. 

  •  For banners, CalendarSet will automatically update the banner start and end date arrays. The banner’s day range will be moved to the a new range of days by determining a difference in days from where it was originally selected and where it was dragged to (e.g. if the banner is selected on the last day of its duration and moved to a new day, the destination of the drag will become the last day of the banner’s new location). 


Note: keep in mind that CalendarSet will update the arrays and refresh the area if (and only if) the drag and drop is within the same area (events or banners to days). Also, dragging onto “out of range” days in the same area will only be allowed if the UnusedInfo parameter to CS_Options is set to CS_Unused_GrayedNumBan.


Receiving a drop from a non-CalendarSet Object


As well as dragging between two CalendarSet areas, you can also drag between non-CalendarSet objects and CalendarSet areas — for example, a row or cell selection from AreaList Pro, another 4D object, a text selection in any (drag and drop savvy) application window or a drop from an external document. 


Receiving a drop from an AreaList Pro area is identified by CS_GetDrgSrcArea returning a negative value (opposite of the AreaList Pro area reference) in the SourceArea parameter and its process in SourceProcessID.


If the source of the drag is an external object, the callback (if set for the area) will be triggered twice:

  • when dragging over the area ($2=CS_Action_DragOver)

  • after the drop ($2=CS_Action_Drop) 


In both cases (and in the 4D object / form method after the drop) the SourceArea from CS_GetDrgSrcArea will be zero and the SourceProcessID will be: 


  • the 4D originating object's process if the source is a 4D object
  • -1 if the source is a document on disk or another application 


Also in both callback calls the content of the dragged and dropped object is a text included in the pasteboard.

Use GET PASTEBOARD DATA to analyze the dragged data and allow the drop (CS_Action_DragOver) or process it (CS_Action_Drop). 


Allowing the drop from external objects in the callback

When dragging from non-plugin objects, you can use a callback method to “catch” the user action and allow it or not (callback methods are set with the CS_SetCallback command). If no callback is set, the drop will be allowed.

In order for external object drag and drop to be disallowed once an area has been made droppable with the “_external” destination access code, the callback method must be set and handle the CS_Action_DragOver case.

See the External documents example below.

AreaList Pro

The source AreaList Pro area is referenced as a negative value in the SourceArea parameter of CS_GetDrgSrcArea (opposite of the AreaList Pro area reference).

Plugin area references use sequential numbering: 1 can be AreaList Pro and CalendarSet area references at the same time, therefore AreaList Pro area #1 will be referenced from CalendarSet's point of view as -1, to differentiate from CalendarSet area #1.

C_LONGINT($srcALPArea) 
If (Form event=On Drop) // here we use the object method, no callback set 
 CS_GetDrgSrcArea(eCal;$sourceArea;$sourceProcess) 
 $srcALPArea:=-$sourceArea //AreaList Pro's area reference (note the minus sign) 
 If ($srcALPArea=ALPappointments) // is this AreaList Pro area our appointment list? 
  // Do something with the appointements 
 End if 
End if 

Refer to the AreaList Pro manual regarding accepting a drop in an AreaList Pro area.

4D

You can use the following code in the On Drop event when accepting a drop from a 4D object:

DRAG AND DROP PROPERTIES($srcObject;$srcElement;$srcProcess) 

Note: $srcObject is Nil if the source 4D object has Automatic Drag enabled.

$srcObject is also Nil if it comes from a different application (or 4D instance).

Then you can use the following code to check what has been dropped:

ARRAY TEXT($4Dsignatures;0)

ARRAY TEXT($nativeTypes;0)

ARRAY TEXT($formatNames;0)

GET PASTEBOARD DATA TYPE($4Dsignatures;$nativeTypes;$formatNames) 

Note: the On Drop event code will work correctly after the drop when used in an area’s object method but in an event callback the form event is zero and drag & drop properties from 4D will not function. However the pasteboard can still be analyzed in the callback with both actions CS_Action_DragOver and CS_Action_Drop.

External documents


After Allowing the drop from external objects in the callback, the CS_Action_Drop action or the On Drop event are used to open the document according to the pathname retrieved from the pasteboard, then process it.

In the following example (available in the CalendarSet demonstration database) we import events from a XML document. We set the callback and allow drop from external documents in the CalendarSet area object method:

Case of

 : (Form event=On Load) 
  CS_SetDrgDst (xCalendar;CS_DragDestination_Day;"_external") // destination days, external only 
  CS_SetCallback (xCalendar;"CSEventCallbackDD") // callback method 
End case 

Then we allow the drop in the callback if the external source is a XML type document, and if such is the case we process it to create our events.

C_LONGINT($1;$2;$0;$i;$elements) // $0 for CS_Action_DragOver only 
C_DATE($date) 
C_TEXT($path;$ref;$xml_Tmp;$xml_Tmp2;$description;$participant;$hour) 
C_BLOB($data) 
Case of 
 : ($2=CS_Action_DragOver)

  $0:=0 // disallow drop unless it is an external XML file

  GET PASTEBOARD DATA("com.4d.private.file.url";$data) // gets file pathname if external document 
  If (OK=1) // something valid in the pasteboard 
   $path:=Get file from pasteboard(1) // first file 
   If ($path="@xml") // is it a XML document? 
    $0:=1 //allowdrop 
   End if 
  End if 
 : ($2=CS_Action_Drop) // was tested above so we know it is a valid XML document 
  GET PASTEBOARD DATA ("com.4d.private.file.url";$data) //gets file path name again (could be a global) 
  $path:=Get file from pasteboard(1) // first file

  $ref:=DOM Parse XML source($path;False)

  If (OK=1) 
   CS_GetDrgDstDay ($1;$date) // day where dropped 
   $elements:=DOM Count XML elements($ref;"event") 
   For ($i;1;$elements) // get each item 
    $xml_Tmp:=DOM Get XML element($ref;"event";$i;$data) 
    $xml_Tmp2:=DOM Get XML element($xml_Tmp;"participant";1;$participant) 
    $xml_Tmp2:=DOM Get XML element($xml_Tmp;"description";1;$description) 
    $xml_Tmp2:=DOM Get XML element($xml_Tmp;"hour";1;$hour)

    APPEND TO ARRAY(vDDRecDates;$date)

    APPEND TO ARRAY(vDDRecDesc;$participant+" : "+$description)

    APPEND TO ARRAY(vDDRecTimes;Time($hour)) 
   End for

   DOM CLOSE XML($ref)

   Area_Refresh ($1) // inform CalendarSet 
  End if 
End case 

Commands

CS_GetDrgArea

(AreaRef; DestArea; DestProcessID)

Parameter Type Description
→ AreaRef longint area reference of CalendarSet object on form
← DestArea longint ID of the area the item was dragged to
← DestProcessID longint process ID of the DestArea

This command is obsolete and should no longer be used. Use CS_GetDrgSrcAreaCS_GetDrgSrcArea in the destination area instead.


CS_GetDrgDstDay

(AreaRef; DestDate)


Parameter Type Description
→ AreaRef longint area reference of CalendarSet object on form
← DestDate date day which received the last drop

If the destination of the last drop was a day (See CS_GetDrgDstTyp), use CS_GetDrgDstDay to determine the destination date. The AreaRef parameter must be the destination (receiver) area of a drop.

DestDate — Date. The day that received the last drop.

Example

// eDestCal object method (On Drop event) 
C_LONGINT($sourceArea;$sourceProcess) 
C_INTEGER($actionCode;$type) 
C_DATE(vDate) 
CS_GetAction(eDestCal;$actionCode) // determine user action 
Case of 
 :($actionCode=CS_Action_Drop) // user dropped an event or banner 
  CS_GetDrgSrcArea(eDestCal;$sourceArea;$sourceProcess) 
  If($sourceProcess=Current process) // was the drag from an area in this process? 
   If ($sourceArea=eDestCal ) // if dragged within the same area 
    CS_GetDrgDstTyp(eDestCal;$type) // get the type of data that was destination of the drag 
    If($type=CS_DragDestination_Day) // if dragged onto a day 
     CS_GetDrgDstDay(eDestCal;vDate) // get day’s date 
    End if 
   End if // $sourceProcess=Current process 
  Else // dropped from a different process 
   VARIABLE TO VARIABLE($sourceProcess;vDate;vDate) // send the date to the source process 
  End if 
End case 

CS_GetDrgDstEvt

(AreaRef; DestType; EventOrBannerIndex)

Parameter Type Description
→ AreaRef longint area reference of CalendarSet object on form
→ DestType integer day, event or banner
← EventOrBannerIndex integer index into corresponding array element

If the destination of the last drop was an event or banner (see CS_GetDrgDstTyp), use this command to determine which event or banner was the destination. The AreaRef parameter is the destination (receiver) area of a drop.

DestType — Integer, 1 or 2. Values are shown below:

Type Value Constant
Event 1 CS_Type_Event
Banner 2 CS_Type_Banner

Note: the values above are different from the CS_SetDrgDst and CS_GetDrgDstTyp data types. The constants used are the same as in CS_GetEvtSelect and CS_SetEvtSelect

EventOrBannerIndex — Integer. Index within the array that was passed to CalendarSet via either CS_SetArray or CS_SetBanrArray.

Example

In this example we use the callback method set for the area, to handle receiving a drop from the eSrcCal area in the same process (where banner arrays are prefixed by “src”).

We assume that our area has been set droppable to any data type, using CS_SetDrgDst.


If a banner is dragged from the source CalendarSet area and dropped on a banner in our area, we decided that it should be removed from the source area (for the example).

// eDestCal callback method

C_LONGINT($1)  // area reference.

C_LONGINT($2)  // action code

C_LONGINT($sourceArea;$sourceProcess) // source area reference (where drag was initiated) ; its process 
C_INTEGER($type;$sourceIndex;$destIndex) // data type ; array index 
Case of 
 : ($2=CS_Action_Drop)  // drop received 
  CS_GetDrgSrcArea($1;$sourceArea;$sourceProcess) 
  If($sourceArea=eSrcCal) & ($sourceProcess=Currentprocess)  // drag from eSrcCal in the same process 
  CS_GetDrgSrcEvt($1;$type;$sourceIndex) // no need for date here, we can use only 3 parameters 
   If($type=CS_Type_Banner) // a banner was dragged 
    CS_GetDrgDstEvt($1;$type;$destIndex) // where was it dropped? 
    If($type=CS_Type_Banner) // drop was on a banner

     DELETE FROM ARRAY(srcStartDateArray;$sourceIndex) // remove the banner from all arrays 
     DELETE FROM ARRAY(srcEndDateArray;$sourceIndex)
       DELETE FROM ARRAY(srcTextArray;$sourceIndex) 
     DELETE FROM ARRAY(srcFontArray;$sourceIndex) 
     DELETE FROM ARRAY(srcSizeArray;$sourceIndex) 
     DELETE FROM ARRAY(srcStyleArray;$sourceIndex) 
     DELETE FROM ARRAY(srcForeColorArray;$sourceIndex) 
     DELETE FROM ARRAY(srcBackColorArray;$sourceIndex) 
     Area_Refresh ($sourceArea) // inform CalendarSet 
    End if // drop was on a banner 
   End if // a banner was dragged 
  End if // drag from eSrcCal in the same process 
End case 

CS_GetDrgDstTyp

(AreaRef;DestDataType)

Parameter Type Description
→ AreaRef longint area reference of the CalendarSet area
← DestDataType integer day, event or banner

CS_GetDrgDstTyp is used to determine the type of data that was the destination of the last drop. Specifically, the user may drag items to either a day, an event, or a banner. After the drop has completed, CS_GetDrgDstTyp indicates whether the destination of the drag was a day, event, or banner. The AreaRef parameter is the destination (receiver) area of a drop.

DestDataType — Integer, 0 to 3. Indicates what type of data was the destination of the last drop. Values are shown below:

Destination Value Constant
No destination 0 CS_DragDestination_None
Day 1 CS_DragDestination_Day
Event 2 CS_DragDestination_ Event
Banner 3 CS_DragDestination_ Banner

See the example to CS_GetDrgDstDay.


CS_GetDrgSrcArea

(AreaRef; SourceArea; SourceProcessID)

Parameter Type Description
→ AreaRef longint area reference of the CalendarSet area
← SourceArea longint ID of the area the item was dragged from
← SourceProcessID longint process ID of the SourceArea

Use CS_GetDrgSrcArea to determine the source area of the last drop. The AreaRef parameter is the destination (receiver) area of a drop.

This command is called from the destination area’s object/form method (or callback method receiving a action code of CS_Action_Drop in $2).

SourceArea — Long integer. This parameter is the area reference of the area that is the source of the drag.

SourceProcessID — Long integer. This parameter contains the process ID in which the window and source area Reside.

Note: if the SourceProcessID is different from the current process, you will need to use 4D’s process communication commands to exchange values with the process that contains the source area.

See the example to CS_GetDrgDstDay and CS_GetDrgDstEvt.


CS_GetDrgSrcEvt

(AreaRef; DataType; EventIndex; StartDate)

Parameter Type Description
→ AreaRef longint area reference of the CalendarSet area
← DataType integer type of item dragged
← EventIndex integer index into corresponding array element
← StartDate date starting date of the drag

Use CS_GetDrgSrcEvt to determine whether an event or banner was dragged and which event or banner it was.

The AreaRef parameter is the destination (receiver) area of a drop. This command is called from the destination area’s object / form method (or callback method receiving a action code of CS_Action_Drop in $2).

DataType — Integer, 1 or 2. Values are shown below:

Type Value Constant
Event 1 CS_Type_Event
Banner 2 CS_Type_Banner

EventOrBannerIndex — Integer. This parameter is an index within the array that was passed to CalendarSet via either CS_SetArray or CS_SetBanrArray.

StartDate — Date. For events, this date will the event’s date passed in CS_SetArray. For banners, this date will be the starting point of the drag, which will be a value between the banner’s start and end dates, inclusively.

See the example to CS_GetDrgDstEvt.


CS_GetDrgDst

(AreaRef; DestDataType; DstCode1; DstCode2; … ; DstCode10)

Parameter Type Description
→ AreaRef longint area reference of the CalendarSet area
→ DestDataType integer data type to be received
→ DstCodeN text access code(s) to allow drop

CS_SetDrgDst is used to enable dropping into a CalendarSet destination area, by setting the access codes for the destination of the drop. Please read the section What are access “codes”? for more information.

This command must be called before a drag is initiated (usually in the On load form event processing).

The AreaRef parameter is the destination (receiver) area of a drop.

DestDataType — Integer, 1 to 3. Indicates what type of data can be a destination of a drop:

Destination Value Constant
Day 1 CS_DragDestination_Day
Event 2 CS_DragDestination_Event
Banner 3 CS_DragDestination_Banner

For the data type specified by DestDataType (either day, event or banner), you must specify at least one DstCode to enable receiving of that type.

DstCode — Text. The DstCode can be any value (other than an empty string), such as “MonthDrag”, “WeekDrag”, “ALPDrag”, etc.

The code should be the same as what is passed into a potential drag partner. The drag partner will be the source/ sender of the drag. The source area can be the same CalendarSet area, a different CalendarSet area, or an AreaList Pro area.

CalendarSet performs the following logic when the drag and drop takes place: the destination codes that were given in DstCode1, DstCode2, etc. are compared to the sender's source codes, previously set with CS_SetDrgSrc.

If any of the codes match, the drop is enabled. 
 In addition, the “_external” special access code must be used as a destination access code in order to make a CalendarSet area droppable from external object. See Allowing the drop from external objects in the callback.

  • “_external” can only be used as a destination access code and is the only way to make a CalendarSet area accept a drop from objects other that CalendarSet or AreaList Pro areas

  • “_external” as a destination access code means “drop onto this CalendarSet area from any external object”

Examples

// enable dragging events to events within this area

  vSelfStr:="CalendarSetArea"+String(eCal) // only allows dragging and dropping within this area 
CS_SetDrgSrc(eCal;CS_DragSource_EventBanner;vSelfStr) // event data type for source 
CS_SetDrgDst(eCal;CS_DragDestination_Event;vSelfStr) // event data type for destination 
 // enable dragging from another CalendarSet area (to days or events) or an external object (to days or banners) 
CS_SetDrgDst(eMonthCal;CS_DragDestination_Day;"WeekToMonth";"_external") // allow dragging into days 
CS_SetDrgDst(eMonthCal;CS_DragDestination_Event;"WeekToMonth") // allow dragging into events 
CS_SetDrgDst(eMonthCal;CS_DragDestination_Banner;"_external") // allow dragging into banners 

CS_SetDrgSrc

(AreaRef; SourceDataType; SrcCode1; SrcCode2; … ; SrcCode10)

Parameter Type Description
→ AreaRef longint area reference of the CalendarSet area
→ SourceDataType integer type of item dragged
→ SrcCodeN text access code(s) to allow drag

CS_SetDrgSrc is used to enable dragging out of a CalendarSet source area, by setting the access codes for the source of the drag. Please read the section What are access “codes”? for more information.

This command must be called before a drag is initiated (usually in the On load form event processing).

The AreaRef parameter is the source (sender) area of a drag. 
 SourceDataType — Integer, 2. Currently, only events and banners can be dragged from CalendarSet:

Source Value Constant
Event or banner 2 CS_DragSource_EventBanner

SrcCode — Text. The SrcCode can be any value (other than an empty string), such as “MonthDrag”, “WeekDrag”, “ALPDrag”, etc.

The code should be the same as what is passed into a potential drag partner. The drag partner will be the destination/receiver of the drag. That destination can be the same CalendarSet area, a different CalendarSet area, or an AreaList Pro area.

CalendarSet performs the following logic when the drag and drop takes place: the source codes that were given in SrcCode1, SrcCode2, etc. are compared to the receiver's destination codes, previously set with CS_SetDrgDst.

If any of the codes match, the drop is enabled. 
 In addition, any source access code will make a CalendarSet area draggable to external object.

See the examples to CS_SetDrgDst.

Note: events and banners, though set by the same SourceDataType value, behave a bit differently.To be draggable, both events and banners must be selectable (and a source access code must be present), but the default values differ:


drag_and_drop_commands.txt · Last modified: 2017/09/07 23:30 by cs_admin