File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
test/manual-test-examples/addons/p5.dom/radio_test Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ < html >
2+ < head >
3+ < script language ="javascript " type ="text/javascript " src ="../../../../lib/p5.js "> </ script >
4+ < script language ="javascript " type ="text/javascript " src ="../../../../lib/addons/p5.dom.js "> </ script >
5+ < script language ="javascript " src ="sketch.js "> </ script >
6+ </ head >
7+
8+ < body >
9+ </ body >
10+ </ html >
Original file line number Diff line number Diff line change 1+ var radio ;
2+
3+ function setup ( ) {
4+ radio = createRadio ( ) ;
5+ radio . id ( 'test' ) ;
6+ //radio = createSelect(); // for comparison
7+
8+ // just mucking around
9+ radio . option ( 'apple' , '1' ) ;
10+ radio . option ( 'orange' , '2' ) ;
11+ radio . option ( 'pear' ) ;
12+
13+ // Set what it starts as
14+ radio . selected ( '2' ) ;
15+
16+ radio . changed ( mySelectEvent ) ;
17+ }
18+
19+ function draw ( ) {
20+ background ( 0 ) ;
21+ if ( radio . selected ( ) === '1' ) {
22+ background ( 255 , 0 , 0 ) ;
23+ }
24+ }
25+
26+ function mySelectEvent ( ) {
27+ var selected = this . selected ( ) ;
28+ console . log ( this . value ( ) ) ;
29+ if ( selected === 'pear' ) {
30+ console . log ( "it's a pear!" ) ;
31+ }
32+ }
33+
You can’t perform that action at this time.
0 commit comments