cancel
Showing results for 
Search instead for 
Did you mean: 

Custom container: Hide and invalidate contents

RReta.1
Associate III

I am aware of this discussion:

https://community.st.com/s/question/0D53W00000uYapRSAS/how-can-we-iterate-containers-inside-a-container-ie-nested-container

In my setup I made a custom container called messageBanner.

In its constructor, it creates and adds its widgets like this:

add(backGroundColorRed); // Solid box with color
add(backGroundColorBlue); // Solid box with color
add(backGroundColorGreen); // Solid box with color
add(bannerText); // Textbox with OneWildcard
add(actionButton); // FlexButton

the actionButton has a virtual function callback called onActionButtonClick

The default behaviour is to "dismiss" the messageBanner, which means to hide all the widgets and stop further touch events to be processed.

This seems to work, but I want to confirm if I am missing something.

// actionButton virtual function callback
void messageBanner::onActionButtonClick(void)
{
        // Iterate and make everything not visible
        Drawable* containerItem = this->getFirstChild();
        while (nullptr != containerItem) {
            containerItem->setVisible(false);
            containerItem = containerItem->getNextSibling();
        }
        // Then make the container not touchable and refesh its display
        this->setTouchable(false);
        this->invalidate();
}

Questions:

  1. this-> in this context points to a messageBanner object, correct?
  2. Is calling this->setTouchable(false); the correct way to stop processing touch events for all widgets inside the container, or should I call actionButton.setTouchable(false); specifically?
  3. does calling this->invalidate(); Invalidates all the child item, or is that should be called for each containerItem. (i.e. inside the loop?)

Thanks for everyone's time...

0 REPLIES 0