ClickPoint Event
The ClickPoint event is triggered when the user clicks a field that is set to a bias of FB_CLICKPOINT.
This event has the following syntax:
on clickpoint [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 ClickPoint event block:
TriggerField
Specifies the field with a bias of FB_CLICKPOINT that was clicked by the user.
This value must match the OriginatorField value.
OriginatorField
Specifies the field specified in the initial on clickpoint statement.
This value must match the TriggerField value.
XStart
Specifies the x coordinate of the click, relative to the TriggerField
YStart
Specifies the y coordinate of the click, relative to the TriggerField
The values in XStart and YStart are in 1000ths of an inch, relative to the upper left corner of the field that received the click.
Use the CurFrame system variable to access these attributes. For more information, see
FrameExec Class.
Usage: The ClickPoint event is defined for all form fields. This event is not defined for menu fields.
The ClickPoint event, which you can use when the user clicks field, can determine the exact coordinates of the click. To access these coordinates use the FrameExec
XStart Attribute and
YStart Attribute.
You can use this event to detect ClickPoints on a composite field (or when fields overlap) and you want to ignore whether the click was on a child field (or on the background of the composite field).
To do so, set the bias of all the child fields to FB_VISIBLE and set the bias of the composite field to FB_CLICKPOINT. Then use the ClickPoint event block for the composite field.
The ClickPoint event is often used with image fields and image trim fields. For example, assume that your application displays a large image field named mapfield, which shows a map of the world. When the user clicks a country in the world map, you want to display a second, more detailed map of the country. To do this, your application must first know what country the user clicked. You can use a ClickPoint event to determine this information:
initialize()=
declare
x_coordinate_of_click = integer;
y_coordinate_of_click = integer;
country_name = varchar(100);
enddeclare
begin
...
field(mapfield).CurBias = FB_CLICKPOINT;
/* ...or specify in the property sheet */
...
end
...
on clickpoint mapfield =
begin
x_coordinate_of_click = CurFrame.XStart;
y_coordinate_of_click = CurFrame.YStart;
country_name = callproc convert_to_country
(x_point = x_coordinate_of_click,
y_point = y_coordinate_of_click,
mapheight = field(mapfield).Height,
mapwidth = field(mapfield).Width);
new_frame = openframe detail_map(country =
country_name);
end
This code example translates coordinates into meaningful names. For instance, the convert_to_country procedure translates the abstract click point into a country name. Then the code calls a new frame to display a map of that country.
You can also use the ClickPoint event in visual editor applications. By providing a ClickPoint event on a subform within a form, you can detect user clicks and then create appropriate display objects at the point of the click.
The following code demonstrates this behavior for creating small elliptical shapes at the point of the click:
initialize(
ellipse = EllipseShape) =
...
on clickpoint test_subform =
begin
ellipse = EllipseShape.Create();
ellipse.FillColor = color;
ellipse.FillPattern = FP_SOLID;
ellipse.LineWidth = LW_NOLINE;
ellipse.XLeft = CurFrame.XStart - 50;
ellipse.YTop = CurFrame.YStart - 50;
...
ellipse.ParentField = field(test_subform);
/* Add to display */
end
For information about how to process ClickPoint events for a set of fields, see
ChildClickPoint Event.
More information: