From 0fa623f444aeaaad81a086e4f3099e1197a8af99 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 26 Sep 2025 22:45:44 +0300 Subject: [PATCH] pass ui handle in `Plugin::on_ui_message` --- fyrox-impl/src/engine/mod.rs | 2 +- fyrox-impl/src/plugin/mod.rs | 7 +++++-- template-core/src/lib.rs | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fyrox-impl/src/engine/mod.rs b/fyrox-impl/src/engine/mod.rs index 9bc84985c..fcdd7329c 100644 --- a/fyrox-impl/src/engine/mod.rs +++ b/fyrox-impl/src/engine/mod.rs @@ -2124,7 +2124,7 @@ impl Engine { }; for plugin in self.plugins.iter_mut() { - plugin.on_ui_message(&mut context, &message); + plugin.on_ui_message(&mut context, &message, ui); } } } diff --git a/fyrox-impl/src/plugin/mod.rs b/fyrox-impl/src/plugin/mod.rs index 0c07aa6ae..661c33505 100644 --- a/fyrox-impl/src/plugin/mod.rs +++ b/fyrox-impl/src/plugin/mod.rs @@ -42,6 +42,7 @@ use crate::{ }; use fyrox_core::define_as_any_trait; use fyrox_core::visitor::error::VisitError; +use fyrox_ui::UserInterface; use std::{ ops::{Deref, DerefMut}, path::Path, @@ -317,12 +318,14 @@ pub trait Plugin: PluginAsAny + Visit + Reflect { fn on_graphics_context_destroyed(&mut self, #[allow(unused_variables)] context: PluginContext) { } - /// The method will be called when there is any message from main user interface instance - /// of the engine. + /// The method will be called when there is any message from a user interface (UI) instance + /// of the engine. Use `ui_handle` parameter to find out from which UI the message has come + /// from. fn on_ui_message( &mut self, #[allow(unused_variables)] context: &mut PluginContext, #[allow(unused_variables)] message: &UiMessage, + #[allow(unused_variables)] ui_handle: Handle, ) { } diff --git a/template-core/src/lib.rs b/template-core/src/lib.rs index 15a37cea1..e259df550 100644 --- a/template-core/src/lib.rs +++ b/template-core/src/lib.rs @@ -159,7 +159,7 @@ dylib-engine = ["fyrox/dylib"] use fyrox::{ core::pool::Handle, core::visitor::prelude::*, core::reflect::prelude::*, event::Event, - gui::message::UiMessage, + gui::{message::UiMessage, UserInterface}, plugin::{Plugin, PluginContext, PluginRegistrationContext}, scene::Scene, }; @@ -205,6 +205,7 @@ impl Plugin for Game { &mut self, _context: &mut PluginContext, _message: &UiMessage, + _ui_handle: Handle ) { // Handle UI events here. }