From 2d34998c312cc052688cabfa94e3557db9ee0b3c Mon Sep 17 00:00:00 2001 From: luigi-rosso Date: Mon, 14 Aug 2023 19:18:01 +0000 Subject: [PATCH] Event triggering 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()) { // Do something with the url. auto url = event->as()->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: CleanShot 2023-08-10 at 18 03 22@2x 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) --- .rive_head | 2 +- wasm/submodules/rive-cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.rive_head b/.rive_head index 4b1e6085..f69ef3f0 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -e71ae68ba09767f246bf3d779f38bb731cf7da9a +8caa7d377f368af8c667ca209a2ce7aef8679be2 diff --git a/wasm/submodules/rive-cpp b/wasm/submodules/rive-cpp index 00866e55..7a06c740 160000 --- a/wasm/submodules/rive-cpp +++ b/wasm/submodules/rive-cpp @@ -1 +1 @@ -Subproject commit 00866e552a4ed1a1b344f0b7320c72952aab455a +Subproject commit 7a06c7404ce4422c5c6be7c986b95d408b840073