This class is meant as an emulation of SCButton. last mod: 17-jul-09 sciss
Also refer to JSCView for different behaviour affecting all widgets
different behaviour | |
states_, font_ | gadget needn't be refreshed explicitly |
colors | are slightly different (a little less contrast); default bg is light grey not clear |
Note: please use the abstraction layer Button if possible!
A push button gadget with support for multiple states (labels/colours). Each state is defined as an array
[ <(String) name>, [ <(Color) textColor>, [ <(Color) backgroundColor> ] ] ]
And all states are given by the states_
method as an array of these arrays. State changes can be detected by assigning a function using the action_
method.
Example:
( w = JSCWindow.new; b = JSCButton( w, Rect( 20, 20, 340, 30 )); b.states = [ // array of states [ "suffering", Color.black ], // first state [ "origins of suffering", Color.white, Color.black ], // second state etc. [ "cessation of creating suffering", Color.red, Color.white ], [ "the path to cessation of creating suffering", Color.blue, Color.clear ] ]; b.action = { arg button; button.value.postln; }; w.front; ) // change the state without calling the action function b.value = 2; // changes the value and calls the action function if it results in a change of value b.valueAction = 3; //if you want to make sure the action function is called, use a combo of these: b.value = 3; b.doAction; // values are clipped to size of states b.valueAction = -1; // floats are truncated to integer values b.valueAction = 3.3; // you can change the font of the button text (see also JSCFont) b.font = JSCFont( "Serif", 20 );
space bar | next state |
return | next state |
csr right | next state |