InitialFocus

Component instance property of a non-modal form that determines whether it immediately gets input focus. It can only be set when using newinstance.

For example:

newinstance"M_FORM", "MyInstance", "InitialFocus=True | False"

Value

Description

True New instance of a non-modal form gets input focus initial input focus
False Input focus stays with the instance that already had it

Description

By default, when a new instance of a form is activated, it gets input focus. However, there are cases when this is undesirable, especially when working with popup forms and secondary windows. By setting the InitialFocus property, you can ensure that input focus initially stays with the form that already has it.

Alternatively, you can implement the same behavior by setting the edit /nofocus in the form being instantiated.

Creating and Deleting Popup Form that has no Focus

The following example creates a new instance of the form a_form as a popup form, but does not give the new instance input focus.

trigger detail ; of FIELD_A
variables 
  string vList
endvariables

  putitem/id vList, "windowtype", "popup"
  putitem/id vList, "initialfocus", "false"

  newinstance "m_form","pop_instance", vList

end; detail

If FIELD_A loses focus, you can close the "pop_instance" component instance in the loseFocus trigger:

trigger loseFocus ; of FIELD_A
   deleteinstance "pop_instance"
end; loseFocus

Applies To

Non-modal Forms

Related Topics