Skip to main content
Associate II
July 15, 2026
Question

Feature Request: hide modal on shade press

  • July 15, 2026
  • 2 replies
  • 25 views

Request: Add an option to the ModalWindow to hide the modal when the shade is pressed. Also add a switch in the Properties panel in Designer

This can be implemented as simply as:
 

namespace touchgfx
{

class ModalWindow: public Container
{
public:
ModalWindow:
// ...
shadePressedCallback(this, &ModalWindow::shadePressedCallbackHandler),
shadeWasPressed(false),
hideOnShadePressed(false)
{
backgroundShade.setClickAction(shadePressedCallback);
windowContainer.setTouchable(true);
}

// ...

// some setter/getter for `hideOnShadePressed`

void shadePressedCallbackHandler(const Box &box, const ClickEvent &event)
{
bool pressed = event.getType() == ClickEvent::PRESSED;
if (hideOnShadePressed && &box == &backgroundShade && shadeWasPressed && !pressed)
{
hide();
}
shadeWasPressed = pressed;
}
protected:
// ...
Callback<ModalWindow, const Box&, const ClickEvent&> shadePressedCallback;
bool shadeWasPressed;
bool hideOnShadePressed;
};

}

 

2 replies

Associate II
July 15, 2026

Tested with:

Associate II
July 15, 2026

Or to make it more general and provide a callback that gets executed when the shade is pressed