Quantcast

Updating Button States on the GUI (without pressing the button)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Updating Button States on the GUI (without pressing the button)

JamessemaJ
This post has NOT been accepted by the mailing list yet.
Hi everyone, I'm trying to get a GUI button to change states to reflect values stored in a corresponding array (named a). So if a[0][0] is changed from 0 to 1, I'd like the corresponding button to change states. How would I do this?

Many thanks

x = 16; y = 20;
w = Window("squares", Rect(0, 0, x * 25, y * 25)).front;
a = 0!x!y;
a.do{ |rows, i|
        rows.do{ |cell, j|
                Button(w, Rect(j*25, i*25, 25, 25))
                .states_([
                        [" ", Color.black, Color.white],
                        ["-", Color.white, Color.black],
                ])
                .action_{ |v|
                        a[i][j] = v.value;
                        v.value.postln;
                };
        };
};
Loading...