You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cycle through those options repeatedly using the selected(value) function
Expected: you should be able to cycle through the options repeatedly
Actual: the radio buttons get stuck on the last option
Snippet:
constoptions=["foo","bar","baz"];functionsetup(){noCanvas();noLoop();letradio=createRadio();options.forEach((v)=>radio.option(v));radio.selected("foo");letix=0;letnextButton=createButton("Next");nextButton.mouseClicked(()=>{constopt=options[++ix%options.length];radio.selected(opt);});letfixButton=createButton("Fix");fixButton.mouseClicked(()=>{// override radio.selected with a version that works properlyletself=radio;// Here's the fix:self.selected=function(value){letresult=null;if(value===undefined){for(constoptionofself._getOptionsArray()){if(option.checked){result=option;break;}}}else{// deselect all first (Google Chrome wigs out when multiple options have the checked attribute set to true)self._getOptionsArray().forEach(option=>option.removeAttribute("checked"));for(constoptionofself._getOptionsArray()){if(option.value===value){option.setAttribute("checked",true);result=option;break;}}}returnresult;};});}functiondraw(){}
The text was updated successfully, but these errors were encountered:
Most appropriate sub-area of p5.js?
p5.js version
1.4.1
Web browser and version
Chromium 98, Safari 15.3, FireFox 96
Operating System
MacOS
Steps to reproduce this
Steps:
selected(value)
functionExpected: you should be able to cycle through the options repeatedly
Actual: the radio buttons get stuck on the last option
Snippet:
The text was updated successfully, but these errors were encountered: