processing / processing/processing4
Improve PApplet draw method's documentation or behavior
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: agreyson
Description
A subclass of PApplet that overrides draw and invokes super.draw (which could happen inadvertently if using an IDE such as IntelliJ that auto-completes overridden methods) will not respond to user events (e.g. mouse clicks). Currently, this is a tricky bug to fix unless a developer is savvy enough to hunt down this GitHub repository and read the implementation of the PApplet draw method. There is a print statement in the implementation that might provide a clue, but it's currently commented out. Uncommenting and providing more details in that print statement would be helpful. For example, you could advise the developer to reconsider invoking super.draw, and explain that it will suspend event handling. (That said, perhaps a better solution would be for the PApplet draw method not to assume that it's being invoked because the subclass has not overridden draw.)
Expected Behavior
public void draw() {
// if no draw method, then shut things down
System.out.println("You're either not overriding the draw method or invoking super.draw from your draw method.");
System.out.println("If the latter, are you sure you mean to do this? Invoking super.draw will suspend event handling.");
finished = true;
}
Current Behavior
public void draw() {
// if no draw method, then shut things down
//System.out.println("no draw method, goodbye");
finished = true;
}
Steps to Reproduce
- Subclass PApplet.
- Override the draw method in the subclass.
- Invoke super.draw from the new draw method.
Your Environment
- Processing version: 4.1.1
- Operating System and OS version: macOS Ventura 13.1
- Other information: I'm using IntelliJ, not the Processing application, and I'm subclassing PApplet and adding the Processing library to my program.
Possible Causes / Solutions
As I mentioned above, a clarifying comment would be a decent compromise if assigning true to finished in the PApplet draw method cannot be avoided.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza por el método PApplet.draw y reproduce el caso de subclase descrito en el issue, en el que draw invoca a super.draw y el manejo de eventos se detiene. Determina si el resultado previsto es una advertencia más clara o un cambio de comportamiento, y verifica el resultado elegido con la reproducción en tres pasos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- api
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100