Language Reference Guide : Events : ChildMoved Event
 
Share this page          
ChildMoved Event
The ChildMoved event is triggered for a composite field when a child field, set to a bias of FB_MOVEABLE or FB_FLEXIBLE, receives a Moved event. The trigger occurs when the move is complete.
This event has the following syntax:
on childmoved [compositefieldname]
compositefieldname is optional if you specify the event in a field script, the composite field name is optional, or if the composite field is the frame's top form.
The following attributes of the FrameExec class can be used in the ChildMoved event block:
TriggerField
Specifies the field with a bias setting of FB_MOVEABLE or FB_FLEXIBLE that the user moved
OriginatorField
Specifies the composite field specified in the initial on childmoved statement
SelectedList
Specifies the set of fields that are currently selected within the frame as a whole.
Use the CurFrame system variable to access these attributes. For more information, see FrameExec Class.
Usage: The ChildMoved event is defined for all composite fields, including the subform that is the frame's top form. If you specify this event in the frame script without a composite field name, the ChildMoved event is triggered when a Moved event occurs on any field that is set to a bias of FB_MOVEABLE or FB_FLEXIBLE.
The ChildMoved event can be used in visual editor applications that provide a type of composite field canvas (usually a subform) on which the user can manipulate shapes or fields. Workbench's Frame Editor is an example of a program that uses the ChildMoved event. In this application, fields or shapes are set to a bias of FB_MOVEABLE or FB_FLEXIBLE, and the user can move and resize objects on the screen using mouse drags.
For example, the following code lets users interactively move and resize the shapes that they create. Each time the user selects, moves, or resizes a field, the following event block executes to store the new screen coordinates of the field:
on childselect test_subform,
on childmoved test_subform,
on childresized test_subform =
begin
CurFrame.TriggerField.GetAttribute(
    XLeft = byref(startx),
    YTop = byref(starty),
    XRight = byref(endx),
    YBottom = byref(endy)
    );
end
Test_subform is the name of the composite field on which the user is creating and manipulating shapes. The event block uses the GetAttribute method to obtain the coordinate values for the field's location. The trigger field is the field that was selected, moved, or resized, causing the event. For more information, see GetAttribute Method.
Note:  If the user moves a group of fields in a single action, a ChildMoved event is generated for each field that is moved.
You can specify a Moved event block for a field and a ChildMoved event block for one or more of the enclosing composite fields for the field. OpenROAD executes the event blocks as described in Event Block Execution.
More information:
OriginatorField Attribute
SelectedList Attribute
TriggerField Attribute