Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
How to paste text to a p5.js canvas from clipboard

I have used

let copy = true;
export const textPaste = () => copy;

function myFunction() {
  
  navigator.clipboard.writeText(copyText.value);

  alert("Copied the text: " + copyText.value);
}

document.querySelector('#textBtn').addEventListener('click', myFunction);

to copy text from a text area to clipboard But when I try to paste it onto my canvas the canvas doesn't respond.

for pasting I used:

/* eslint-disable no-undef */
import { textPaste } from "./textHelper.js";

function textInput() {
  this.icon = "./assets/textInput.png";
  this.name = "textInput";

  let drawing = false;
  let startMouseX = -1;
  let startMouseY = -1;

  this.draw = function () {
    if (mouseIsPressed) {
      if (startMouseX === -1) {
        startMouseX = mouseX;
        startMouseY = mouseY;
        drawing = true;
        // save the current pixel Array
        loadPixels();

        if (mouseIsPressed) {
          document.getElementById("myInput").value;
          async function paste(input) {
            const text = await navigator.clipboard.read();
            input.value = text;
          }
        }
      }
    } else if (drawing) {
      // save the pixels with the most recent rectangle and reset the
      // drawing tool and start locations
      const copy = textPaste();
      set(startMouseX, startMouseY, copy);

      loadPixels();
      drawing = false;
      startMouseX = -1;
      startMouseY = -1;
    }
  };
}

export default textInput;
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda