Get each items in a container and change item attribute
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-07 2:40 AM
Hi,
I have some flexbuttons in a container.
I'd like to change let's say the border size of all flexbuttons inside that container when one flexbutton is pressed.
Is there a way to do it with some kind of foreach loop ? like: for each item in the container, if the item is a flexbutton, item.changeBorderSize(10);
thanks!
Solved! Go to Solution.
- Labels:
-
TouchGFX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-07 6:47 AM
I remember looking into this a while ago but I gave up and just created an array of pointers to each widget I wanted to iterate through, with the reasoning that I know my objects at compile-time anyway. These container methods may be useful to you if you still want to try and iterate through the container. Would be interested to know if anyone has accomplished what you described.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-07 6:47 AM
I remember looking into this a while ago but I gave up and just created an array of pointers to each widget I wanted to iterate through, with the reasoning that I know my objects at compile-time anyway. These container methods may be useful to you if you still want to try and iterate through the container. Would be interested to know if anyone has accomplished what you described.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-07 11:14 PM
thanks for the workaround!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-01 5:06 AM
Hi,
Step 1
class DoThisToEveryChild : public GenericCallback< Drawable & >
{
virtual void execute ( Drawable & d ) final
{
// user code here e.g.
// d.setVisible ( false );
}
virtual bool isValid () const final
{
return true;
}
};
Step 2
DoThisToEveryChild doThis {};
// now 'DoThisToEveryChild::execute ()' will be called for every child in 'ticks' container
ticks.forEachChild ( & doThis );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-19 3:44 AM
This is the correct way to iterate through container or screen elements
void Task_Stopped::handleClickEvent(const ClickEvent &evt)
{
Drawable *d = getFirstChild();
while (d)
{
d->handleClickEvent(evt);
d = d->getNextSibling();
}
}
