Adapting to viewport changes
Application forms and functions can be adapted to the front-end viewport size or mobile device orientation.
This feature is deprecated, its use is discouraged although not prohibited.
The windowresized
predefined action has been introduced to
let programs adapt the forms to the screen size or mobile screen orientation. Starting with Genero
V4, to adapt dynamically the forms to the screen, consider defining forms with Responsive Layout instead. The
windowresized
predefined action is deprecated.
Detecting viewport size / orientation changes
When the mobile device orientation changes, or when the current window is resized on
desktop/web front-ends, the windowresized
specific predefined action will be sent, if
an ON ACTION
handler is defined by the current dialog for this
action.
The windowresized
action is used only to hide/show items on the current form
using the standard user interface API (
ui.Form.setElementHidden()
) and it is not recommended for reloading forms on
the fly.
This predefined action can be used to detect viewport geometry changes and adapt the application form to the new size:
ON ACTION windowresized
-- Code to adapt to the new viewport size
In dialogs allowing field input (INPUT
/ INPUT ARRAY
or
CONSTRUCT
), take care of the current field input: The windowresized
action can force the field validation. Therefore, it is not recommended to use this special action
in these dialogs. The action can be safely used in DISPLAY ARRAY
and MENU
dialogs.
windowresized
action is used, consider setting action default attributes for
this action in your .4ad file as
follows:<ActionDefaultList>
...
<ActionDefault name="windowresized" validate="no" defaultView="no" contextMenu="no"/>
...
</ActionDefaultList>
ON ACTION
handler:ON ACTION windowresized ATTRIBUTES(VALIDATE=NO, DEFAULTVIEW=NO)
...
Querying the geometry of the viewport
DEFINE size STRING
CALL ui.Interface.frontCall("standard","feInfo",["windowSize"],[size])
IF size == "1200x1824" THEN
...
END IF