OpenInsight now includes the ability to implement Drag and Drop capabilities within you application. This document outlines the concept, elements, events and properties of Drag and Drop within OpenInsight.
Drag and Drop functionality is built around three basic elements:
These elements interact with each other in the following way:
The Drag Source is defined as the control or window that is capable of having data dragged from it. It is responsible for:
In OpenInsight, a window or control is flagged as a Drag Source by setting its ENABLEDRAG property to TRUE$, either dynamically at runtime, by setting a PS style bit in the Form Designer or through the use of the ADD_DND system tool.
The Data Object is created to hold the data that is to be dragged. This data does not necessarily have to be in one format. Applications that use Drag and Drop frequently place more than one format in the Data Object – this allows target controls and applications to pick which format they prefer giving the Drag and Drop operation more chance of success.
The Data Object is populated by the Drag Source when the drag operation begins, and queried by a Drop Target during and on completion of a drag drop process.
The Data Object is created and managed internally by OpenInsight. It may be modified by the Drag Source when first created during a DRAGSTART event, and queried by the Drop Target during the DRAGOVER and DROPDROP events.
When created, OpenInsight usually fills the Data Object with one or more data formats.
A Drop Target is defined as a control or window that can accept and respond to notifications that data is being dragged over it. It is responsible for:
In OpenIsight, a window or control is flagged as a drop target by setting it’s ENABLEDROP property to TRUE$, either dynamically at runtime, by setting a PS style bit in the Form Designer or through the use of the ADD_DND system tool.
The following properties are used to control the basic Drag and Drop operations:
Set this property to TRUE$ to enable data to be dragged from a control. OpenInsight will monitor mouse messages sent to the control and will detect if the user attempts to drag data from them.
Applies To : All controls except OLE controls.
Remarks:
See also: DRAGSOURCE property, DRAGSTART, DRAGEND events
Set this property to TRUE to allow selected rows to be dragged in an edit table. If this flag is not set only data from single cells is allowed to be dragged (if their COLSTYLE is set accordingly).
Applies To: EDITTABLE
Remarks:
See also: ENABLEDRAG property, COLSTYLE message.
Set this property to TRUE$ to allow combobox drag source controls to register their list component as a drag source too.
Applies To: COMBOBOX controls
Remarks:
See also: ENABLEDRAG property
Set this property to TRUE$ to mark the control as a drop target, which means that the control will be notified when data is dragged over it.
Applies To: All controls except OLE controls.
Remarks:
See also: DROPTARGET property, DRAGOVER, DRAGDROP events
Set this property to TRUE$ to allow a drop target control to response to mouse hover notifications while data is dragged over it. In most cases this performs automatic scrolling of the drop target control when near the edge of the control’s client area.
Applies To: All controls except OLE controls.
Remarks:
Set this property to TRUE$ to allow a hierarchical lisbox drop target control to response to mouse hover notifications but expanding a node automatically.
Applies To: Hierarchical LISTBOX controls
Remarks:
Set this property to TRUE$ to allow simple combobox drop target controls to register their list component as a drop target too.
Applies To: Simple COMBOBOX controls
Remarks:
The following properties apply to the SYSTEM object:
Contains the name of the OpenInsight control that is the “drag source” during a drag-drop operation. Read-only.
Contains the name of the OpenInsight control that is currently the target of a DragDropoperation (if any). Read-only.
The following properties apply to the current Drag Source control. The majority of them are only effective during a DRAGSTART event:
Contains a number specifying which mouse button was used to start the drag operation. Read-only.
Applies To: The control that is currently the drag source (see the SYSTEM DRAGSOURCE property)
Contains the cell position of data being dragged from an edit table in the format:
Column : @fm : Row
Applies to: EDITTABLE when the control is currently the drag source (see the SYSTEM DRAGSOURCE property) and cell data is being dragged.
See also: DRAGTEXTSELECTION property.
Returns or sets a flag denoting if the drag source allows a COPY operation. This property should be set during the DRAGSTART event to override the default copy setting.
Applies To: Any control that is flagged as drag enabled (i.e. it’s ALLOWDRAG property is TRUE).
See also: ALLOWDRAG, DRAGMOVE properties.
Contains an @fm-delimited list of data formats being dragged. Read-only.
Applies To: The control that is currently the drag source (see the SYSTEM DRAGSOURCE property)
Remarks:
Control Type | Formats | Notes |
---|---|---|
BITMAP | BITMAP | |
FILENAME | (if applicable) | |
COMBOBOX (Item) | TEXT | |
COMBOBOX (List) | OI_LIST | @fm-delimited list |
TEXT | CRLF-delimited list | |
EDITLINE | TEXT | |
EDITBOX | TEXT | CRLF-delimited text |
EDITTABLE (Cell) | TEXT | |
EDITTABLE (Rows) | OI_EDT_ROWLIST | @fm/@vm-delimited list |
TEXT | CRLF/TAB delimited list | |
LISTBOX | OI_LIST | @fm-delimited list |
TEXT | CRLF-delimited list |
See also: GETDRAGDATA, SETDRAGDATA, REMOVEDRAGDATA and CLEARDRAGDATA messages
Returns or sets a flag denoting if the drag source allows a MOVE operation. This property should be set during the DRAGSTART event to override the default move setting.
Applies To: Any control that is flagged as drag enabled (i.e. it’s ALLOWDRAG property is TRUE).
See Also: ALLOWDRAG, DRAGCOPY properties.
Contains the client coordinates of the mouse (i.e relative to the control’s client area) when the drag operation started. Read-Only.
Property is returned in the format:
xPos : @fm : yPos
Applies To: The control that is currently the DragSource (see the SYSTEM DRAGSOURCE property)
Contains the number of rows being dragged from a row-oriented control.
Applies To: LISTBOX, EDITTABLE when the control is currently the drag source (see the SYSTEM DRAGSOURCE property) and row data is being dragged.
See also: DRAGSELROWS property
Contains the row numbers of the data being dragged from a row-oriented control. Multiple row numbers are @fm delimited.
Applies To: LISTBOX, EDITTABLE when the control is currently the drag source (see the SYSTEM DRAGSOURCE property) and row data is being dragged.
See also: DRAGSELROWCOUNT property
This property contains the starting point and length of selected text used for a drag operation in the format
startPos : @fm : length
Applies to: EDITLINE, EDITBOX, EDITTABLE when the control is currently the drag source (see the SYSTEM DRAGSOURCE property)
The following messages apply to the current Drag Source control. The majority of them are only effective during a DRAGSTART event:
This message is used to extract data of a specified format from a dragged data object. It may be used against both drag source and drop target controls in all drag-drop related events.
dragData = Send_Message( ctrlEntID, “GETDRAGDATA”, format, unicode, maxlen)
Arguments
Argument | Description |
---|---|
ctrlEntID | Must be a current drag source or drop target control (See the SYSTEM DRAGSOURCE and DROPTARGET properties) |
format | Name of the format that you want to extract. This can be a custom format or one of the following standard OI data formats: “TEXT” - Returns dragged textual data and automatically handles any Unicode translations required “FILENAME” - Returns a dragged filename. “BITMAP” - Returns a dragged bitmap handle. See notes below regarding dragged bitmap handles for further information. |
unicode | When using a custom textual format set this flag to true for OI to perform a Unicode to UTF8/ANSI translation automatically if you know the data is a Unicode string. |
maxlen | When using a custom format and extracting binary data set this to the maximum number of bytes that OI should extract. |
Returns
The dragged data for the specified format.
Remarks
This message is used to set the data for a nominated format for a drag source control.
retVal = Send_Message( ctrlEntID, “SETDRAGDATA”, format, unicode, data )
Arguments
Argument | Description |
---|---|
ctrlEntID | Must be a current drag source control (See the SYSTEM DRAGSOURCE property) |
format | Name of the format that you want to set. This can be a custom format or one of the following standard OI data formats: “TEXT” - Sets textual data in both ANSI and Unicode format “FILENAME” - Sets a filename data format. “BITMAP” - Sets BITMAP a bitmap data format. The data should be a bitmap path (see BITMAP property) |
unicode | When using a text-based custom format set this flag to true for OI to perform a UTF8/ANSI to Unicode translation automatically before setting the data. |
data | The data to set. |
Returns
TRUE$ if the data was set correctly, FALSE$ otherwise
Remarks
This message is used to remove the specified data format from the dragged data.
retVal = Send_Message( ctrlEntID, “REMOVEDRAGDATA”, format )
Arguments
Argument | Description |
---|---|
ctrlEntID | Must be a current drag source control (See the SYSTEM DRAGSOURCE property) |
format | Name of the format that you want to remove. This can be a custom format or one of the following standard OI data formats: “TEXT” - Sets textual data in both ANSI and Unicode format “FILENAME” - Sets a filename data format. “BITMAP” - Sets BITMAP a bitmap data format. The data should be a bitmap path (see BITMAP property) |
Returns
TRUE$ if the data was removed, FALSE$ otherwise
Remarks
This message removes all data from the drag source data object. This can be used during a DRAGSTART event to cancel the drag if you wish.
retVal = Send_Message( ctrlEntID, “CLEARDRAGDATA”, format )
Arguments
Argument | Description |
---|---|
ctrlEntID | Must be a current drag source control (See the SYSTEM DRAGSOURCE property) |
Returns
TRUE$ if the data was removed, FALSE$ otherwise
Remarks
This message sets the bitmap used by the system when dragging data from the drag source.
retVal = Send_Message( ctrlEntID, “SETDRAGBITMAP”, bmp, xOffset, yOffset, tc )
Arguments
Argument | Description |
---|---|
ctrlEntID | Must be a current drag source control (See the SYSTEM DRAGSOURCE property) |
bmp | Path of the bitmap image to use – see the BITMAP property. |
xOffset | X offset of the image from the cursor hotspot |
yOffset | Y offset of the image from the cursor hotspot |
tc | Color to use as the transparent color if the image has transparent parts |
Returns
TRUE$ if the image was created, FALSE$ otherwise
Remarks
These events apply to a control registered as a “drag source” (i.e. it’s ENABLEDRAG property is TRUE).
This event is fired in response to a drag operation beginning on a control. This means that the user has clicked a mouse button down on a control and has begun to drag. The main tasks that should be addressed in this event are (in no particular order):
Event Parameters
Parameter | Description |
---|---|
MouseDownX | x coordinate where the drag started (relative to the client area) |
MouseDownY | y coordinate where the drag started (relative to the client area) |
CtrlKey | TRUE$ if the Ctrl key was held down when the drag was started |
ShiftKey | TRUE$ if the Shift key was held down when the drag was started |
AltKey | TRUE$ if the Alt key was held down when the drag was started |
MouseButton | Denotes which mouse button was held down when the drag was started: ‘0’ - Left Mouse Button ‘1’ - Right Mouse Button ‘2’ - Middle Mouse Button |
Remarks
This event is fired after a drop operation has ended and is used to inform the drop source of the results of the operation. The main tasks that should be addressed in this event are (in no particular order):
Event Parameters
Parameter | Description |
---|---|
DragResult | Result of the DragDrop operation. Can be one of the following: ‘CANCEL’ ‘COPY’ ‘MOVE’ |
Remarks
Set to FALSE$ during a DRAGOVER event to stop OI performing any more data comparisons against the drop target until the control is entered again.
Applies To: The control that is currently the drop target (see the SYSTEM DROPTARGET property)
See also: DRAGFORMATLIST, DROPFORMATLIST properties, DRAGOVER, DRAGDROP events
Remarks
* This property is basically an optimization technique. If you are sure that the control will not accept the current drag data at any point during the operation then set this property to FALSE$ will save processing time. * It is reset to TRUE$ whenever drag data enters the control again (i.e. the DRAGOVER ENTER event)
Set this property to TRUE$ to allow the drag data to be copied to the drop target.
Applies To: The control that is currently the drop target (see the SYSTEM DROPTARGET property)
See also: DRAGMOVE property, DRAGOVER, DRAGDROP events
Remarks
Returns an @fm delimited list of data formats being dragged. Read-only. OI compares the list of formats defined in the control’s DROPFORMATLIST property against the formats in the DRAGFORMATLIST property to determine if a drag can be made or not.
Applies To: The control that is currently the drop target (see the SYSTEM DROPTARGET property)
See also: Drop Source DRAGFORMATLIST property, DRAGOVER, DRAGDROP events
Returns an @fm delimited list of data formats accepted by the control and should be sorted in order of preference. During DRAGOVER events the system will examine the data being dragged and compare it to the formats in this list, selecting the first match it finds.
Applies To: Any control defined as a drop target.
See also: DRAGOVER, DRAGDROP events. DROPTARGET property.
Used during the DRAGDROP event to let the system know what operation took place. Can be either “MOVE” or “COPY”.
See also: DRAGDROP event
Set this property to TRUE$ to allow the drag data to be moved to the drop target.
Applies To: The control that is currently the drop target (see the SYSTEM DROPTARGET property)
See also: DRAGCOPY property, DRAGOVER, DRAGDROP events
Remarks
When set during a DRAGDROP event it prevents the OI from performing any default data copy or move operations after the event returns. Basically you are saying that you have handled all operations necessary and that OI should perform no further processing after the DRAGDROP event returns.
Values you may set are:
This value will be passed to the DRAGSOURCE DRAGEND event if appropriate.
Applies To: The control that is currently the “drop target” (see the SYSTEM DROPTARGET property)
Remarks: This property can only be set during a DRAGDROP event. If is reset to null at the start of every DRAGDROP event.
These events apply to controls registered as “drop targets” (i.e. one of the following properties is TRUE: ENABLEDROP,ENABLEDROPHOVER or ENABLEDROPEXPAND).
This event is fired at a drop target control in response to data being dragged into, over and out of it. For this reason there are four separate subcategories:
1. DragEnter: Data has been dragged into the drop target. The main tasks that should be addressed at this point are (in no particular order):
2. DragMove: Data is being dragged across a control. The main tasks that should be addressed at this point are (in no particular order):
3. DragHover: The mouse is hovering over the control while dragging data. The main tasks that should be addressed at this point are (in no particular order):
4. DragLeave: The data has been dragged out of the control without being dropped. The main tasks that should be addressed at this point are (in no particular order):
Event Parameters
Parameter | Description |
---|---|
DragEvent | Describes the type of DRAGOVER event taking place. Can be one of the following: “ENTER” - Data has been dragged onto a control for the first time “MOVE” - Data is being dragged across a control “HOVER” - Mouse is hovering above a control with dragged data “LEAVE” - The data has been dragged outside of the control |
MouseX | x coordinate of the mouse (relative to the client area) |
MouseY | y coordinate of the mouse (relative to the client area) |
CtrlKey | TRUE$ if the Ctrl key is held down |
ShiftKey | TRUE$ if the Shift key is held down |
AltKey | TRUE$ if the Alt key is held down |
MouseButton | Denotes which mouse button is being held down: ‘0’ - Left Mouse Button ‘1’ - Right Mouse Button ‘2’ - Middle Mouse Button |
Remarks
This event is fired at a drop target control when the user has dropped data onto it. The main tasks that should be addressed at this point are (in no particular order):
Event Parameters
Parameter | Description |
---|---|
DataFormat | Contains the name of the dropped data format |
DropResult | Contains the desired action – MOVE or COPY. |
xDown | x coordinate where the data was dropped (relative to the client area) |
yDown | y coordinate where the data was dropped (relative to the client area) |
CtrlKey | TRUE$ if the Ctrl key was held down when the data was dropped |
ShiftKey | TRUE$ if the Shift key was held down when the data was dropped |
AltKey | TRUE$ if the Alt key was held down when the data was dropped |
MouseButton | Denotes which mouse button was held down when the data was dropped: ‘0’ - Left Mouse Button ‘1’ - Right Mouse Button ‘2’ - Middle Mouse Button |
Remarks