The Focus ID

Every function for drawing graphics includes a FocusID parameter. VTScada does not force you to set a unique value for each ID since there are situations where it is desirable to use one value for several objects. (For example, disabling several AddressEntry fields by setting their FocusID values to 0.)

A graphic only needs a unique focus ID value if you intend to use the NextFocusID function to give it the focus, or the FocusID() function to see if it has the focus. Otherwise, best practice is to give every active control the focus ID of 1.

Tab order between user input controls follows their z-order (that is, the order of the statements within the state), rather than their Focus ID value.

The function, NextFocusIDcan be used to set the focus to the next item with a certain focus ID number. FocusIDreturns the focus ID number of the item that has focus.

Note that the above refers to keyboard focus. If several overlapping objects can react to a mouse-click then that click will be used by all the overlapping objects. It does not matter that only one has focus.

Placing Focus on an Object vs. Selecting an Object

There is a difference between an object being selected, and an object that has the focus on a page. It is very important to note that an object that has the focus is not necessarily selected. In a sense, focus can be thought of as a property while selection is a command.

For example, it is possible to force the input focus to a certain graphic object by means of a NextFocusID statement. When dealing with statements that combine an If function and a GUIButton function, it is important to keep in mind that you may focus the button, but the script paired with the If function will not be executed until the button is actually pressed (either by the keyboard or the mouse).

An object that has the focus is ready for input from the user. If the object is an edit field for example, the cursor will blink within the field, indicating that it is ready for input. If the object with the focus is a button, it is highlighted when selected. In order for an object that has the focus to be selected, it must be clicked by the mouse, or the <TAB> key, or the <RETURN> or <ENTER> key must be pressed.

Focus movement (on a tab key) or reverse tab (i.e. Shift + Tab keys)) is based on the order that statements appear in the source code. This applies recursively to calling sequences in steady state. For example:

ZButton(...1...); 
ChildMod(); 
ZButton(...2...); 

In this example, ZButton(...1...) would be first in the focus order, followed by any focusable statements in ChildMod, followed by ZButton(...2...).

Launched modules will appear in the focus order after steady state focusable statements and steady-state calling sequences.

For example:

If Watch(1); 
[ 
  LaunchedMod(); 
] 
ZButton(...1...); 
ChildMod(); 
ZButton(...2...); 

In the above sequence, the focus order will be the same as that of the previous example above, with the addition of any focusable statements in LaunchedMod, after ZButton(...2...).