PennController for IBEX › Forums › Support › Multiple use of the same object › Reply To: Multiple use of the same object
Hello Jeremy,
Thank you for your answer! I didn’t express myself precisely enough.
I have 9 buttons (speed, consumption, hp,… – like on a car quartet card) that generate text on the left or right of one of 10 canvases, depending on a variable, which are filled one after the other.
So I have a total of 18 possible pieces of text that the user can generate by pressing one of the buttons. Each of these 18 pieces of text should be able to appear several times on one of the 20 possible places (left or right on the respective canvas).
My question now is: Can I place 20 hidden text elements (instead of preparing 20*9 elements) on the canvas and pass them the corresponding selected text element? I know there is no set method for the text elements, but can I work around this?
This is a part of the code to make my description easier to understand.
Thanks a lot!
Christin
newButton ("PS", "Leistung "+ "<br>"+ variable.LeistungPS + " PS") , //... newText("PS1", "Der "+variable.model + " hat eine Leistung von " + variable.LeistungPS + " PS") , newText("PS2", " er hat eine Leistung von " + variable.LeistungPS + " PS.") , //... newCanvas("canvas1",780,20 ) .settings.add( "right at 100%", "middle at 50%", getButton("+1").print()) .css( "border" , "solid 1px black" ) , newCanvas("canvas2",780,20 ) .settings.add( "right at 100%", "middle at 50%", getButton("+2").print()) .css( "border" , "solid 1px black" ) .settings.hidden() , //... newCanvas("canvas10",780,20 ) .css( "border" , "solid 1px black" ) .settings.hidden() , //... newVar("site", "left at 0%"), //left or right on the canvas newVar("mid", "middle at 50%"), newVar("nr", "1"),//Text1 or Text2 newVar("canvasnr_button", "canvas1"), //canvas where the text should appear, changes when Button "+" is pressed getButton("PS") .callback( newFunction( ()=>{ try { getCanvas(getVar("canvasnr_button")._element.value).add( getVar("site")._element.value, getVar("mid")._element.value, getText("PS" + getVar("nr")._element.value)) ._runPromises(); } catch (e) { } }).call(), getVar("mid").set("middle at 50%"),getVar("nr").set("2"), getVar("site").set("left at 55%") ), //...