The PushGhost/PopGhost functions are useful in scripts where an object is created, and the user must click to place the object. The object's outline can be drawn and attached to the pointer, facilitating placement. Example:
array[2000] # create some shape in array, nverts is actual size ... ShowPrompt("Click to locate new object"); xy[2] PushGhost(array, nverts) ShowGhost(8) if !Point(xy) Exit() end ShowGhost(0) PopGhost() # use xy to create object in database
0 | Turn off ghosting |
1 | full-screen horiz line, snapped to grid |
2 | full-screen vert line, snapped to grid |
3 | full-screen horiz line, not snapped |
4 | full-screen vert line, not snapped |
5 | vector from last point location to pointer |
6 | box, snapped to grid |
7 | box, not snapped |
8 | display polygon list from PushGhost |
9 | vector from last point location to pointer |
10 | vector from last point location to pointer |
11 | vector from last point location to pointer |
The modes 5, 9, 10, and 11 draw a vector from the last button 1 down location to the pointer. Mode 5 snaps to the grid, and snaps the angle to multiples of 45 degrees when the angle is close. If the Constrain45 variable is set, the angle is strictly constrained to multiples of 45 degrees. Mode 9 is similar, but does not snap to grid. Mode 10 is similar, but there are no angle constraints, except that implicit in snapping to the grid. Mode 11 is similar, but there are no angle constraints and no grid snapping.
With the ghosting enabled, the Point function returns coordinates that are snapped to grid or not depending on the mode passed to ShowGhost. Modes 1, 2, 5, 6, 8, and 10 are snapped to grid.
If the UseTransform function has been called to enable use of the current transform, the current transform will be applied to the displayed objects when using mode 8. The translation supplied to UseTransform is ignored (the translation tracks the mouse pointer).