スキップしてメイン コンテンツに移動

投稿

ラベル(textArea)が付いた投稿を表示しています

Blogger で p5js textarea scrollbar

この間のスクロールバー云々をBlogger上でデモ <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.5.0/p5.js"></script><div id="p5canvas"></div> <script> let myTextArea; function setup() { createCanvas(400, 300).parent("p5canvas"); // init textarea myTextArea = createElement('textarea').parent("p5canvas"); myTextArea.attribute("rows","5"); myTextArea.attribute("cols","20"); myTextArea.value('0\n1\n2\n3\n4\n5\n6\n7\n0\n1\n2\n3\n4\n5\n6\n7'); myTextArea.position(20,20); } function draw() { background(220); text(" scrollTop "+myTextArea.elt.scrollTop ,20,280); } </script>

p5js textarea scrollbar ではまったので残しておく

20220928 p5jsでtextareaをつかいたかったのと スクロールバーのスクロール具合を知りたかったので調べたら 2日ほど潰れてくやしいので記録しておく scrollTopの前にeltをつければ良いみたい 正道かどうかは不明 ブラウザのデバッグモードの要素のイベントリスナーの blurのwindowのhandlerの[[scopes]]のスクリプトのmyTxtareaの eltでその他のメンバーが見られるので必要がアレば探そう p5js ウェブエディターで以下のコードで検証 let myTextArea; let btnname=['A','B']; let butn=[]; function aset(){   myTextArea.elt.rows=5;   myTextArea.elt.scrollTop=50; } function bset(){   myTextArea.elt.rows=10;   myTextArea.elt.scrollTop=100;   } function setup() {   createCanvas(400, 550);   // init textarea   myTextArea = createElement('textarea');   myTextArea.attribute("rows","10");   myTextArea.attribute("cols","50");   myTextArea.value('0\n1\n2\n3\n4\n5\n6\n7\n0\n1\n2\n3\n4\n5\n6\n7');   myTextArea.position(20,20);      //init buttons   for(let i=0;i<btnname.length;i++){     butn[i] = createButton(btnname[i]);     butn[i].position(20+i*50, 230);   }   butn[0].mouse...