cancel
Showing results for 
Search instead for 
Did you mean: 

Get each items in a container and change item attribute

Emilmart
Senior

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Michael K
Senior III

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.

View solution in original post

3 REPLIES 3
Michael K
Senior III

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.

thanks for the workaround!

ferro
Senior II

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 );