processing / processing/processing4

keyPressed() does not always fire after starting sketch

Abierto
#766 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Java
Estrellas
494
Forks
183
Merge medio
4 h 39 min
PR fusionados (30 d)
3

Descripción

Created by: sterretjeToo

When starting a sketch from the IDE or running an exported sketch, it does not always react on keyboard input; sometimes one has to click inside the drawn area. So it looks like a started sketch does not have the focus; clicking on the titlebar in the window does not solve the issue.

The below sketch (running in the IDE) produces the issue (as said, it sometimes works correctly, sometime not).

void setup()
{
  size(400, 200);
}

void draw()
{
}

void keyPressed()
{
  println("keyPressed()");
}

Expected behaviour

The expected behaviour is that at the moment that the sketch runs and a key is pressed, the message "keyPressed()" shows.

System information

Second gen Intel I3 with 8GB memory and integrated Intel Graphics (AsRock H61M VS-R2.0)
Windows 10 Home
Processing 4.3; the issue was also observed in Processing 4.2)

Workaround

https://discourse.processing.org/t/keypressed-only-works-sometimes/22340 (July 1920) contains a (possible) workaround by using the below line in setup()

  surface.setVisible(true);

For now, it seems to have solved the issue. I will provide feedback if I still encounter the issue with the above workaround.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Ejecuta el sketch mínimo proporcionado tanto desde la IDE como en un sketch exportado en Windows, comprobando si keyPressed() se activa inmediatamente sin hacer clic en el área de dibujo. Empieza comparando el comportamiento de inicio del sketch y el comportamiento del foco/la visibilidad de la ventana, incluido el workaround indicado surface.setVisible(true). Se considera terminado cuando la entrada de teclado funciona de forma fiable inmediatamente después del inicio en ambos casos.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java
Área
desktop
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.