2.131 .focus
In a dialog, normally there is exactly one object which can have the keyboard focus. It is displayed in the usual manner of the underlying window system.
.focus is an attribute with a few special characteristics:
- It cannot be inherited from a model or a default.
- It cannot be indicated when defining the object.
- The data type of the attribute depends on the type of the object and the type of the access
- SetVal: only setting of the focus is possible, the reset is done automatically by the IDM.
Definition
-
Data type
boolean
-
Access
get, set
-
changed event
no
SetValue
The object has to be real_visible and real_sensitive.
If the relevant window is the active window of the application, the focus is set and displayed.
If the relevant window is not the active window of the application, setting the focus is done only internally and stored as savedfocus
.
If a window is deactivated or reactivated, the focus is set again on the object which last had the focus, i.e. the focus is always stored with reference to the window as savedfocus
. However, this is only valid as long as the window exists in the window system.
The focus can only be set, resetting is done automatically by the DM.
The data type for normal objects is boolean. Only true is accepted, false is rejected as an error.
The following expressions are therefore permitted in the rule syntax:
Lb.focus := true; Pb.focus := true; Wn.focus := true;
Object |
Behavior for .focus |
---|---|
Canvas |
Focus is set at the relevant canvas and the associated canvas function CCR_focus is called. If the canvas is not in the visible area of the parent, the necessary scroll operations are carried out. See Also Chapter “Specific Attributes” in the “Object Reference” |
Groupbox |
The focus is set at first object (in groupbox) that is real_sensitive and real_visible. The search begins with the first child of the window, goes on to the first child's children and finally to the first child's siblings. If an object is found which can have the focus, the focus is set at this object. If no object is found, the focus is not taken from the actual focus-object, i.e. the focus remains unchanged. |
Checkbox |
The focus is set at the indicated object and displayed in the object specific manner. If the object is currently not visible in its parents' area, the scroll operations necessary for making the object visible are carried out. |
Edittext |
|
Listbox |
|
Poptext |
|
Pushbutton |
|
Radiobutton |
|
Rectangle* |
|
Scrollbar |
|
Statictext |
|
Menubox |
not valid |
Menuitem |
not valid |
Tablefield |
Focus is set at the corresponding tablefield. To set the focus to a specific field, a double index which determines the field coordinates has to be indicated for the attribute focus: .focus[I,J] |
Window |
The focus is set at the first object (in the window) that is real_sensitive and real_visible. The search begins with the first child of the window, goes on to the first child's children and finally to the first child's brothers. If an object is found which can have the focus, the focus is set at this object. If no object is found, the focus is set at the window. |
* Note
The DM object rectangle cannot obtain the focus under Motif, thus this object cannot get the focus. On querying the focus of a rectangle, false is returned.
.focus can be queried for any object. However, the type of return value depends on the object class.
Object |
Data Type |
Return Value |
---|---|---|
Groupbox |
DM_ID |
child (of given object) which has the focus |
Window |
||
Canvas |
boolean |
true, if the focus is on the queried object false, if the queried object does not have the focus. |
Checkbox |
||
Edittext |
||
Listbox |
||
Poptext |
||
Pushbutton |
||
Radiobutton* |
||
Rectangle |
||
Scrollbar |
||
Statictext |
||
Tablefield |
index |
Index (see above) if the tablefield has the focus. In this case, the field specified by the index is accessed. |
* Note for the IDM for Windows
A radiobutton is activated when it obtains the focus!
See Also
Attribute .focusitem