draggraybox
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

- activeobjectaction -- allows a procedure to communicate with the object on the current form that is currently being edited (if any).
- changeobject -- modifies the properties of one object in a form.
- changeobjects -- modifies the properties of one or more objects in a form.
- cloneform -- copies all of the objects in a form (optionally, with modifications) into the active form.
- cloneobjects -- duplicates objects in a form (with modifications).
- closeactiveobject -- closes any object whose text is currently being edited.
- datamode -- switches a form from graphics mode into data mode.
- deleteobject -- deletes the specified object from the current form.
- deleteselectedobjects -- deletes selected objects from a form.
- dragtext -- starts drag-and-drop of text.
- Font Awesome Icons -- are over 600 ready-made icons built right into Panorama.
- formcleanview -- cleans up extraneous NSView objects in the current form.
- formxy -- programmatically scrolls a form to a new position.
- graphicsmode -- switches a form into graphics mode.
- info("activeobject") -- returns the name of the currently active text editor or word processor object (if any).
- info("activeobjectid") -- returns the object ID of the currently active text editor or text list object, if any.
- info("activesuperobject") -- returns the name of the currently active text editor or word processor object, if any.
- info("click") -- returns the location of the last mouse click in screen relative coordinates.
- info("clickedobjectid") -- returns the object ID of the clicked object.
- info("focusobject") -- returns the name of the currently active text editor or word processor object, if any.
- info("focusobjectid") -- returns the object ID of the currently active text editor or text list object, if any.
- info("scrollpoint") -- returns the distance the current form is scrolled horizontally and vertically.
- magicformwindow -- designates an open window as the temporary active window for the purposes of info( functions and graphic statements.
- magicwindow -- designates an open window as the temporary active window for the purposes of info( functions and graphic statements.
- magnification -- changes the magnification of a form.
- Modifiable Object Properties -- describes the properties of graphic objects that can be modified by a program (dimensions, color, font, title, etc.).
- newformobject -- creates a new graphic object in a form.
- object -- selects an object (based on the object name).
- objectaction -- allows a procedure to communicate with an object on the current form.
- objectid -- selects one graphic object in the current form based on an ID number.
- objectinfo( -- returns information about a graphic object: its location, size, color, font, etc.
- objectinfoarray( -- builds a text array of form object properties
- objectnumber -- identifies one graphic object from a set of selected graphic objects in the current form.
- openasyncprogresswindow -- opens a floating progress window for asynchronous operations (urltask(, timers).
- progressalert -- displays a progress alert if an operation is going to take a long time.
- progressbar -- updates a progress bar on the current form.
- selectallobjects -- selects all the graphic objects in the current form.
- selectnoobjects -- unselects all the graphic objects in the current form.
- selectobjects -- uses a formula to select one or more objects in the current form.
- startgraphicschange -- adds undo support to a procedure.
- Text Display Programming -- programming a Text Display Object.
- Text Editor Programming -- programming a Text Editor Object.
- textlisttableoptions -- sets up text list table options
- Web Browser Programming -- programming a Web Browser Object (including JavaScript).
- xytoxy( -- converts a point or rectangle from one co-ordinate system to another.

History

Version | Status | Notes
10.0 | Updated | Carried 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.