Language Reference Guide : 5. Events : ChildClick Event
 
Share this page                  
ChildClick Event
The ChildClick event is triggered for a composite field when one of its child fields receives a Click event. For a MenuGroup, the ChildClick event is triggered when the user selects one of its menu items.
This event has the following syntax:
on childclick [compositefieldname | menugroupname]
compositefieldname is optional if you specify the event in a script for a composite field, or if the composite field is the frame's top form.
The following attributes of the FrameExec class can be used in the ChildClick event block:
TriggerField
Specifies the field that the user clicked on
OriginatorField
Specifies the composite field in the initial on childclick statement
InputFocusField
Specifies the field that has the current input focus
To access these attributes, use the CurFrame system variable of the FrameExec Class.
Usage: The ChildClick event is defined for all menu groups and composite fields, including the subform that is the frame's top form.
The ChildClick event is valid only if the child field is valid for a Click event (entry fields do not take Click events), and only if the child field has an interactive bias (FB_CHANGEABLE or FB_LANDABLE).
You can use the ChildClick event block to:
Process Click events on buttons or image fields that are used as columns within a table field.
The following example shows how a ChildClick event can be used for a table field column. Clicking any cell in the column triggers the event block. The testcolumn is a column of image fields in the testtable table field. The event block also calls the ShowDetail frame when the user clicks any location in the testcolumn column:
on childclick testtable[*].testcolumn =
begin
/* The current row will reflect the row
** that contained the image that was
** clicked. Note that the empty bracket []
** syntax indicates current row.
*/
callframe ShowDetail(picture =
     testtable[].TestColumn);
end
Detect clicks on any number of fields in a composite field.
For example, assume your form has two image fields, image1 and image2. For either image, you might want to reverse the image's pattern when the user clicks the image. You could use two separate Click event blocks, one for each image, as follows:
on click image1 =
begin
field(image1).IsReverse = TRUE;
end

on click image2 =
begin
field(image2).IsReverse = TRUE;
end
Alternatively, you can place the image fields in a named composite field (a subform, flexible form, matrix field, or stack field) and define one ChildClick event block for the composite field, as shown in the following example. Assume that the image fields are contained by a subform named picture_subform. When the user clicks either image field, the following event block is executed:
on childclick picture_subform =
begin
FormField(CurFrame.TriggerField).IsReverse
= TRUE;
end
The TriggerField attribute of the FrameExec object specifies the child field that actually triggered the event (the image on which the user clicked).