Question
Feature Request: hide modal on shade press
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;
};
}
