Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explores an API for triggering events and querying them at runtime. For Flutter we expose an onEvent callback that you can add a callback to on the StateMachineController: ```dart final controller = StateMachineController.fromArtboard(artboard, 'bumpy', onEvent: {); controller.onEvent = (event) { // Do something with event. Like: if(event is OpenURLEvent) { launchUrl(event.url); } }; artboard.addController(controller!); ``` Note that I haven't piped onEvent to the Flutter runtime yet but you'll see it in the StateMachineController in core. In C++: ```c++ auto count = stateMachineInstance->firedEventCount(); for(auto i = 0; i < count; i++) { auto event = stateMachineInstance->firedEventAt(i); if(event->is<OpenURLEvent>()) { // Do something with the url. auto url = event->as<OpenURLEvent>()->url(); } } ``` You can see some of this in action in the state_machine_event_test.cpp. You can also see the events in the console in the editor: <img width="717" alt="CleanShot 2023-08-10 at 18 03 22@2x" src="https://github.com/rive-app/rive/assets/454182/af21902a-424d-435b-b5b0-2a43701fe186"> In a follow up PR: - Ability to trigger events from State (in/out) and Transition (start/end). - Add custom properties to Events C++ API (currently they are loaded but not tracked against their respective events). Diffs= 8caa7d377 Event triggering (#5793)
- Loading branch information