Language Reference Guide : 5. Events : DragSegment Event
 
Share this page                  
DragSegment Event
The DragSegment event is triggered when the user draws a drag segment in a field and the field is set to a bias of FB_DRAGSEGMENT.
This event has the following syntax:
on dragsegment [fieldname]
fieldname is optional if you specify this event in a field script.
The following attributes of the FrameExec class can be used in the DragSegment event block:
TriggerField
Specifies the field with a bias of FB_DRAGSEGMENT where the user dragged the line
OriginatorField
Specifies the field specified in the initial on dragsegment statement
XStart
Specifies the x coordinate of the start of the drag, relative to TriggerField
YStart
Specifies the y coordinate of the start of the drag, relative to TriggerField
XEnd
Specifies the x coordinate of the end of the drag, relative to TriggerField
YEnd
Specifies the y coordinate of the end of the drag, relative to TriggerField
The coordinate values are in 1000ths of an inch and are relative to the upper left corner of the field that received the DragSegment event.
Use the CurFrame system variable to access these attributes. For more information, see FrameExec Class.
Usage: The DragSegment event is defined for all form fields. This event is not defined for menu fields.
The DragSegment event lets you access or reference the beginning and end points of a line drawn by the user. This event is often used in visual editor applications.
By providing a DragSegment event on a subform within a form, you can detect user drags and then create lines at the point of the drag.
The following code demonstrates this behavior for creating segments at the point of drags:
initialize()=
declare
line = SegmentShape;
enddeclare
begin
field(test_subform).CurBias = FB_DRAGSEGMENT;
...
on dragsegment test_subform =
begin
/* The CurFrame variable will have all of the
** details of what the size of the drag was.
*/
line = SegmentShape.Create();
line.LineColor = color;
line.LineWidth = linewidth;
line.Point1X = CurFrame.Xstart;
line.Point2X = CurFrame.Xend;
line.Point1Y = CurFrame.Ystart;
line.Point2Y = CurFrame.Yend;
line.ParentField = field(test_subform);
          /* Add to form */
end
If you want to allow drawing on subfields within test_subform, set the bias of these subfields to FB_VISIBLE.
The XStart and YStart attributes always represent the start of the drag that the user made. The XEnd and YEnd attributes represent the end of the drag. Since a user can drag a segment from right to left or bottom to top, and the more common left to right or top to bottom, you cannot assume that XStart and YStart represent the upper left coordinate of the line.
For information about processing DragSegment events for a set of fields, see ChildDragSegment Event.
More information:
OriginatorField Attribute
TriggerField Attribute
XEnd Attribute
XStart Attribute
YEnd Attribute
YStart Attribute