ForEachLoop - retrieve values one by one on button/key stroke?


I want to make a simple widget what would allow me to switch images by using a button. I got a working sample but it switches to last image in a array - the goal is to switch to next image in array instead of last one.
Can someone please show me how can I get value one by one in order to apply it in the script? I guess the ForEachLoop should hand me current value and pause the loop until next value is requested? How can this be done with blueprints?

Many thanks,



Simple, Set an int variable in your widget, on clicked set the int to int+1, get ScreenImage array, run a get off of that, plug in your int var, and set the brush from that. Also, check your int on the increment to see if it will equal ScreenImage.length. Since arrays work from 0, if your next int == to length of the array, in your image it would be 3, you would be calling something that doesn’t exist. So, if it == 3, or > 2, set it to zero. Also, if it would be ==-1 or < 0, set it to array.length -1.

Thank you, James.
Very helpful, it worked.