Popup Window

A popup window displays a form in a secondary window that is anchored to a field. The position of the popup window is configurable, so that it can be displayed outside or inside the boundaries of its parent field.

Popup windows can be set declaratively by setting the window property Window Type of the popup form to Popup, or in Proc when activating the form.

Note:  Popup forms are not supported in the grid widget. The grid widget and its field cells cannot be used to anchor the popup form.

Specifying a Popup Window

A form can be displayed in a popup window in two ways:

  • Declaratively: Set the Window Type property of the form to Popup, then activate it normally in the calling form:

    ;DETAIL trigger of FLD1
    newinstance "DETAIL_FRM", "Details"
    activate "Details"
  • Procedurally: Activate any form as popup form by specifying windowtype=popup using newinstance:

    ;DETAIL trigger of FLD1
    newinstance "A_FORM", "Details", "windowtype=popup"
    activate "Details"

    In this case, note the following

    • If WindowType is an empty string or illegal value, the popup form is not activated.
    • If WindowType is not specified, the form's default or declared window type is used.

      If the Position and AutoClose properties are also specified, they are ignored, unless the form was declared as a popup window.

      For example, if A_FORM has Window Type Normal, with the following newinstance command, the position and autoclose properties do not work.

      newinstance "A_FORM", "popupForm" ,"windowtype=popup;position=BOTTOMRIGHT_UPRIGHT;autoclose=T"

      If A_FORM's Window Type is Popup, they do.

Popup Window Properties

When a form is defined as a popup form, either in its definition or in the newinstance statement, the following properties are set to the indicated default values:

Property

Value

Auto Close

True

Caption

False

Iconize

False

Close

False

Resizable

False

Modality & Attachment

Non-modal, Detached

Overlay Previous Form

True

Keep Layout State

False

Position

BOTTOMLEFT_DOWNRIGHT

InheritWinProps

False

FieldName

CurrentField

It is possible to set the values of the FieldName, AutoClose, Position, and InheritWinProps by specifying them as instance properties in the newinstance Proc statement. It is not possible to change the other properties. However, if the InheritWinProps property is True, window properties that are explicitly set are inherited from the form definition and are not changed to the popup defaults.

Popup Window with Title Bar

For example, assume that you have defined a normal form and selected the Caption and Close window properties. If you activate it as a popup window and set InheritWinProps=true, the resulting popup form will have a title bar and a close button.

newinstance "A_FORM", "popupForm" ,"windowtype=popup;position=BOTTOMRIGHT_DOWNLEFT;InheritWinProps=T"
activate "popupForm"

Popup form with inherited properties

Note:  A popup form with a title bar opens according to its Position property but will not move with its anchor. If the parent field, rectangle, or form is moved, the opened popup form with title bar stays where it is. It does not move with its parent field. This is contrast to other popup forms, which remain with the parent field and move with it when the field or form is moved.

Cascading Popup Windows

It is possible for one popup form to activate another, creating a cascading chain of popup forms.

If the Auto Close property is True, a popup form that loses focus to a form further down the chain does not close. If it loses focus to a popup form which is further up the chain, all popup windows below the form with focus are closed.

This can be useful if you want to create a field-related popup menu, for example.

Anchor Field of the Popup Window

The popup window uses the current field as its anchor and should be started from a field-level trigger, such as the Detail trigger. At runtime, if no active field can be found when the form instance is created, the popup specification is ignored and an error is returned in Proc.

You can explicitly define the parent field for the popup window using the FieldName window property:

;DETAIL trigger of FLD1
newinstance "DETAIL_FRM", "Details", "windowtype=popup;fieldname=FLD1"
activate "Details"

Position of the Popup Window

The position of the popup window is determined by:

  • The location of its associated field, including how close it is to the edge of the screen. If the field is too close to the boundaries of the screen for the popup window to be displayed as configured, its position is reversed so that it is still displayed.
  • The value of the Position window property, if specified. This property defines a position relative to the widget boundaries, or to a popup rectangle that is defined for the widget. By default, it is BOTTOMLEFT_DOWNRIGHT, so a popup window is displayed below the field, starting from the bottom left corner. For more information, see Position.
  • The value of the PopupRect widget property, if specified. This property defines a rectangle that can be used as anchor point for the popup window instead of the widget boundaries. It is especially useful for large widgets, where you want the popup form to be displayed somewhere within the widget boundaries, but it can also be displayed outside the widget or even outside the application window. For more information, see PopupRect.
  • The presence of a title bar. A popup form with a title bar opens according to its Position property but will not move with its anchor. Since it can be moved by the user, it remains wherever it was opened or positioned, even if the parent field or window is moved. (A popup form has a title bar if its parent component has a title bar and it was started with the InheritWinProps property set to True.)