Add event handler extraction support to rive code generator #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I had claude code write this, but tested the result on all of our Rive files. Please have a look and see if you'd like to include it.
This enhancement enables the rive code generator to extract event handlers from state machines, addressing a limitation where only inputs were extracted but events that could be fired back to the host application were missing.
Changes Made
C++ Code Generator (src/main.cpp):
JSON Template (templates/json_template.mustache):
API Usage
The implementation uses the correct Rive API pattern:
Example Output
Before (only inputs):
After (inputs + events):
Testing
Tested with multiple .riv files including complex state machines with events. The enhancement correctly extracts events while maintaining all existing functionality for inputs, animations, and other data.
Resolves the limitation where event handlers like "monsterTapped" were present in Rive files but not accessible in generated code.