C++ Mode v0.4.8
MouseEvent and KeyEvent support
Mouse and keyboard callbacks now accept an optional event object — matching Java Processing's API exactly. Both zero-arg and event-arg overloads are supported simultaneously:
void mousePressed() { /* old style still works */ }
void mousePressed(MouseEvent e) {
println(e.getButton(), e.isShiftDown(), e.getX(), e.getY());
}
void keyPressed(KeyEvent e) {
println(e.getKey(), e.isControlDown(), e.getAction());
}
void mouseWheel(MouseEvent e) {
println(e.getCount()); // scroll steps
}
Available on all callbacks: mousePressed, mouseReleased, mouseClicked, mouseMoved, mouseDragged, mouseWheel, keyPressed, keyReleased, keyTyped.
Both MouseEvent and KeyEvent expose the full Java Processing method set: getX(), getY(), getButton(), getCount(), getAction(), isShiftDown(), isControlDown(), isAltDown(), isMetaDown(), getKey(), getKeyCode().
Parser fixes
ArrayList<T>and other template types at top level — fixed a bug where trailing-declarator detection consumed the next top-level declaration, causingArrayList<Ball> balls;after a class body to produce a false parse error- Comparison vs template ambiguity —
neighbours < 2 || neighbours > 3no longer triggers a false "unexpected token" error; integer literals and comparison-chained identifiers after<are now correctly identified as comparisons, not template argument lists unionsupport —unionis now fully parsed and emitted alongsidestructandclass- Anonymous structs and unions —
struct { float x, y; } pos;works at top level and inside class bodies - Trailing declarators —
class Foo { ... } *ptr, instance;is fully supported
Linter improvements
The live error underline (linter) now uses the same ClassHoister pass as the real build, so:
- User-defined classes defined after
setup()/draw()are correctly hoisted and visible to the rest of the sketch - Class methods that call Processing API functions (
fill,ellipse, etc.) no longer produce false "cannot call member function without object" underlines - Static member definitions (
int Counter::count = 0;) are correctly placed at file scope, not inside the sketch struct - The linter
_PSketchproxy struct now matches the real generated struct, sowidth,height,mouseX,mouseYetc. are accessible inside hoisted user classes
Engine fixes
PVectorconstructors now accept proxy types (thewidth/heightproxy structs), soPVector(width, height - 20)inside a user-defined class works correctly- All Processing API template functions (
fill,stroke,ellipse,rect, etc.) now accept proxy types viais_convertible_vinstead ofis_arithmetic_v fullScreen(int mode)implementation was missing — calling it caused a linker errorline(A, B, C, D)4-arg template declaration was missing itstemplate<>prefix