Language Reference Guide : 5. Events : SelectionChanged Event
 
Share this page                  
SelectionChanged Event
The purpose of this event is twofold:
1. To indicate that the SelectedList attribute of a FrameExec has been changed
2. To indicate that the user has selected a row in a tablefield
This event has the following syntax:
on selectionchanged [tablefieldname]
tablefieldname is optional if you specify this event in a field script for a table field.
The following attributes of the FrameExec class may be available when the SelectionChanged event occurs. The attributes that are affected depend on the form of the SelectionChanged event:
SelectedList
Specifies the list of selected items in the frame. The SelectedList attribute is affected only when there is no TableField name in the on event statement.
TriggerField
Specifies the TableField that triggered the event. The TriggerField attribute is meaningful only when a TableField name is specified in the on event statement.
ReasonCode
Specifies a code that indicates what type of user action caused the event. The ReasonCode attribute is available only when a TableField name is specified in the on event statement. See the FrameExec ReasonCode Attribute.
Use the CurFrame system variable to access FrameExec attributes. For more information, see FrameExec Class.
Usage: This event is defined only for a tablefield and for a subform that is the frame top form. You can specify this event only in a frame script.
The SelectionChanged event indicates that the user has changed a selection. This event is useful if you want to obtain the SelectedList, without having special code based on the particular field or fields that changed their selection status. It is also useful since a single user action leads to only a single SelectionChanged event.
For example, the user might click the background of a form, which unselects all currently selected fields. Alternatively, the user might use a lasso select on a group of fields, which unselects the currently selected list of fields and selects a new list. It is inefficient to use the ChildSelect and ChildUnSelect events to process these types of events. However, you can get all the necessary information simply by specifying the SelectionChanged event and then examining the SelectedList array attribute of the FrameExec or the IsSelected attributes of the individual fields.
To process the list of selected fields when a change occurs in the selection, you can specify the following code:
on selectionchanged =begin
i = 1;while i <= CurFrame.SelectedList.NumRows() do
/*...field to process is **
CurFrame.SelectedList[i]...*/i = i + 1;
endwhile;
end
You can specify a SelectionChanged event and individual Select events, UnSelect events, ChildSelect events, or ChildUnSelect events. This causes OpenROAD to execute the SelectionChanged event last. Be aware that using a resume statement within a Select, UnSelect, ChildSelect, or ChildUnSelect event block aborts the remaining Select and UnSelect events, including the SelectionChanged event.
When you specify a TableField name and select a row in the specified TableField, the on event statement occurs. The FrameExec TriggerField attribute indicates which table field is associated with the event, and the ReasonCode attribute indicates what user action caused the event. When a TableField name is not specified in the on event statement, the SelectionChanged event is exactly as described in the previous paragraphs and example. For more information about how to determine which TableField rows are selected, see the TableField class _RowSelected Attribute.
The ReasonCode attribute of the FrameExec object identifies the conditions of the SelectionChanged event. For more information, see ReasonCode Attribute.
More information:
SelectedList Attribute