draggraybox
DRAGRECTANGLE
,
LIMITS
,
SLOP
,
AXIS
,
GRAY

The draggraybox statement facilitates dragging something around in a form window.


Parameters

This statement has five parameters:

dragrectangle – is the original co-ordinates of the rectangle the user will drag around. Often these co-ordinates are the same as the co-ordinates for the button the user pressed on. (Note: the co-ordinates for this rectangle, along with the next two, are relative to the upper left hand corner of the screen.) This parameter should be a field or variable (not a more complex formula) because after the user has released the mouse Panorama will copy the final co-ordinates into this parameter.

limits – is the co-ordinates of a boundary rectangle that defines how far the dragrectangle can be dragged in each direction. For example if dragging should only occur inside a particular form object, this parameter should be set to the co-ordinates of that object. If the limits parameter is empty (“”) or missing completely, there will be no limit on how far the rectangle can be dragged. (However, dragging can only occur within the current form window – it cannot cross over to another window.)

slop – is the co-ordinates of a boundary rectangle past the limits boundary. If the user drags the mouse beyond the slop rectangle the dragged item will disappear completely (until the user drags back inside the slop rectangle). If the slop parameter is empty (“”) or completely missing the dragged item will never disappear no matter how far you drag (however, it will always be “pinned” inside the limit rectangle). It’s often a good idea to make the slop rectangle the same dimensions as the limits rectangle or a little larger.

axis – allows the procedure to restrict the direction the rectangle can be dragged to either horizontal or vertical. If the axis parameter is 0 or "" (or missing) the rectangle can be dragged in any direction. If the axis is 1 or horizontal the rectangle can only be dragged horizontally. If the axis is 2 or vertical the rectangle can only be dragged vertically.

gray – if this parameter is set to “gray” or “grey”, this statement will drag a gray box around. If any other value is passed (or this parameter is omitted), an image of the specified area will be dragged.


Description

The draggraybox statement allows a user to drag an item on the screen to a new position. For example, you can use this as part of code that re-arranges the order of items in a list, or customizes the layout of certain items in a form.

The drag operation is initially triggered by a transparent button, or by any graphic object that triggers code when the mouse is pressed (for example a Text Display or Image Display object). The procedure starts by determining the area to be dragged – usually this is the same as the co-ordinates of the triggering button or object, but not necessarily. (To find out the co-ordinates of the triggering object, use the info(“buttonrectangle”) function).

In Panorama 6 and earlier versions, this statement would drag an actual dotted gray rectangle around, hence the name. Now, however, the statement captures an image of the area to be dragged, and drags around a semi-transparent image of that area. (You can force Panorama to do it the old way, dragging a dotted gray rectangle, by setting the 5th parameter to "gray" or "grey".)

When the user lets up on the mouse button the DragGrayBox statement places the final position of the box into the field or variable specified by the first parameter. The procedure can then take whatever action is appropriate (moving a graphic object, copying data, etc.)

The procedure below allows the user to drag a button around the window. When the user releases the mouse, the procedure moves the button to the new location.

local drag,insidewindow
drag=info("buttonrectangle")
selectobjects
    integralrectangle(xytoxy(drag,"s","f")) = integralrectangle(objectinfo("rectangle"))
insidewindow=rectangle(
    rtop( info("windowrectangle"))+20,
    rleft( info("windowrectangle"))+26,
    rbottom( info("windowrectangle"))-16,
    rright( info("windowrectangle"))-16)
draggraybox drag,insidewindow,info("windowrectangle"),0
if drag="" // was mouse released outside slop area?
    stop // yes, so stop
endif
drag=xytoxy(drag,"s","f")
changeobjects "rectangle",drag
selectnoobjects

The procedure below implements drag and drop within a window. When the button is dragged onto the object named Landing Zone, an item is added to the order.

local drag,insidewindow
drag=info("buttonrectangle")
insidewindow=rectangle(
    rtop( info("windowrectangle"))+20,
    rleft(info("windowrectangle"))+26,
    rbottom( info("windowrectangle"))-16,
    rright( info("windowrectangle"))-16)
draggraybox drag,insidewindow,info("windowrectangle"),0
object "Landing Zone"
if inrectangle( xytoxy( info("mouse"),"s","f"),
    objectinfo("rectangle"))
    // dragged into the landing zone, so copy data
   call AddToOrder
endif

See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0, but now by default drags a semi-transparent image of whatever is in the original drag area. Also the slop rectangle no longer defaults to the limit rectangle, and the axis parameter can be specified by text (vertical or horizontal) in addition to by number.