processing / processing/processing4

Improve PApplet draw method's documentation or behavior

Aperta
#789 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Java
Stelle
494
Fork
183
Merge medio
4h 39m
PR unite (30g)
3

Descrizione

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

  1. Subclass PApplet.
  2. Override the draw method in the subclass.
  3. 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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dal metodo PApplet.draw e riproduci il caso di sottoclasse descritto nell'issue, in cui draw invoca super.draw e la gestione degli eventi si interrompe. Determina se il risultato previsto sia un avviso più chiaro o una modifica del comportamento, quindi verifica il risultato scelto con la riproduzione in tre passaggi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
api
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.