Skip to main content
Version: 4.16

ModalWindow

The ModalWindow is a Container type widget that displays a window and blocks touch events to the underlying view and widgets. The ModalWindow consists of a background Image and a Box that acts as a shade over the underlying view and widgets with adjustable alpha. The ModalWindow will fill up the entire screen and should always be added as the last element such that it is always on top of all other elements.

ModalWindow running in the simulator

Widget Group#

The ModalWindow can be found in the Containers widget group in TouchGFX Designer.

ModalWindow in TouchGFX Designer

Properties#

The properties for a ModalWindow in TouchGFX Designer.

Property GroupProperty Descriptions
NameName of the widget. Name is the unique identifier used in TouchGFX Designer and code.
Modal Image LocationX and Y specify the top left corner of the image within the ModalWindow.

W and H specify the width and height of the container within the ModalWindow.
The size of the container within the ModalWindow is taken from the size of the associated image and cannot be altered except by changing the image.

Lock specifies if the widget should be locked in its current X, Y, W and H.
Locking the widget also disables interacting with the widget through the screen.

Visible specifies the visibility of the widget.
Making the widget invisible also disables interacting with the widget through the screen.
AppearanceWindow Image specifies which image the ModalWindow should use.

Shade Color specifies the color of the overlay shade.

Shade Alpha specifies the transparency of the overlay shade.
The alpha value ranges between 0 and 255 for the widget. 0 is fully transparent and 255 is solid.

Interactions#

The actions and triggers supported by the ModalWindow are described in the following sections.

Actions#

Standard widget actionDescription
Hide widgetHides a widget (sets visibility to false).
Show widgetMake a hidden widget visible (sets visibility to true).

Triggers#

The ModalWindow does not emit any triggers.

Performance#

A ModalWindow is a Container type that consists of a Box, a Container and an Image. The ModalWindow does not per default appear in the draw chain. Therefore, the performance is mostly dependent on the childrens drawing performance.

For more general details on drawing performance, read the General UI Component Performance section.

Examples#

Generated Code#

In the generated code for the View base class we can see how TouchGFX Designer sets up a ModalWindow.

mainViewBase.cpp
#include <gui_generated/main_screen/mainViewBase.hpp>
#include "BitmapDatabase.hpp"
#include <texts/TextKeysAndLanguages.hpp>
#include <touchgfx/Color.hpp>
mainViewBase::mainViewBase() :
buttonCallback(this, &mainViewBase::buttonCallbackHandler)
{
modalWindow.setBackground(touchgfx::BitmapId(BITMAP_BLUE_BACKGROUNDS_MAIN_BG_320X240PX_ID), 80, 16);
modalWindow.setShadeColor(touchgfx::Color::getColorFrom24BitRGB(0, 0, 0));
modalWindow.setShadeAlpha(150);
modalWindow.hide();
add(modalWindow);
}
void mainViewBase::setupScreen()
{
}
Tip
You can use these functions and the others available in the ModalWindow class in user code. Remember to force a redraw by calling modalWindow.invalidate() if you change the appearance of the widget.

TouchGFX Designer Examples#

To further explore the ModalWindow, try creating a new application within TouchGFX Designer with one of the following UI templates:

ModalWindow Example UI template in TouchGFX Designer

API Reference#