processing / processing/processing4

Improve PApplet draw method's documentation or behavior

Offen
#789 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Java
Sterne
494
Forks
183
Ø Merge
4 Std. 39 Min.
Gemergte PRs (30 T.)
3

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne bei der Methode PApplet.draw und reproduziere den im Issue beschriebenen Fall mit einer Unterklasse, bei dem draw super.draw aufruft und die Ereignisverarbeitung beendet wird. Ermittle, ob das beabsichtigte Ergebnis eine klarere Warnung oder eine Verhaltensänderung ist, und überprüfe das gewählte Ergebnis anhand der dreistufigen Reproduktion.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
api
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.