QGrid |
Using the plug-in |
QGrid has its own drag and drop mechanism to handle drag and drop of one or more grid cells within the same plug-in area or between different areas, on the same or on different 4D process windows. QGrid's drag and drop is independent from 4D's drag and drop.
Drag and drop setupDrag and drop requires a source object and a target object: items are dragged away from the source and dropped onto the target. In QGrid the source and target objects can be the same QGrid plug-in area or different ones. In the second case the two areas may be in the same or in different 4D process windows.
Having a pair of QGrid areas does not necessarily mean that drag and drop will work; the two areas have to be suitably defined to match. Matching a source to a target is done with a signature-matching mechanism. Signatures are strings that you can freely assign to areas. Before allowing the action, QGrid checks for matching signatures.
More precisely, there are two types of signatures: drag signatures and drop signatures and QGrid allows you to define more of them for each area. Therefore, drag and drop is allowed only if a drag signature of the source area matches a drop signature of the target.
Source area setupTo set up a QGrid area as a drag source, simply define at least one drag signature string for the area. This is done by passing an array of drag signature strings to the command QG_SetDragSignatures:
ARRAY STRING(31;$emittedDragTypes;3) |
This is done in exactly the same way as with drag signatures, only the relevant QGrid command is now QG_SetDropSignatures:
ARRAY STRING(31;$acceptedDropTypes;2) |
In the examples above, there will be a drag and drop between these two grid areas because there is a common signature, "bananas".
Drag and drop feedbackOnce a drag source and a drop target were defined, Drag and Drop is automatically activated: users can drag any (visible) selected grid cell. QGrid automatically provides visual feedback for the drag and drop action: a dotted outline of the on-screen selected cells that tracks mouse movement.
When the user moves over a drop area QGrid compares the source area's drag signatures with the drop signatures of the underlying area. If at least one match is found, an insertion point is drawn between cells of the target area, to indicate the drop position.
If the target area is the same as the source area, QGrid will autoscroll to allow the drop in all points of the grid area contents.
![]() |
Insertion bar thickness, color and shape can be configured with QG_SetDragOptions |
When the user finally releases the mouse button over a grid area, QGrid generates a drop event for that area. You can intercept this event with a properly configured event handler method (see QG_SetEventHandler).
To get more information about the drop source, use QG_GetDragSource. The drop position, i.e. the index of the cell before which the drop occurred, is returned in the eventData
parameter of the event handler.
![]() |
In the case of interprocess drag and drop, keep in mind that QGrid areas (as all plug-in areas) are assigned unique reference values automatically by 4D. This means that you can access a plug-in area from any process by simply using its reference number; no need for interprocess variables, process-to-process communication or other difficult tricks. |