From d4997dff3965b262a635818a23bbfdad1fe7c60c Mon Sep 17 00:00:00 2001 From: hodasemi Date: Tue, 4 Mar 2025 16:03:57 +0100 Subject: [PATCH] improve click callback builder --- src/elements/callback_builder.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/elements/callback_builder.rs b/src/elements/callback_builder.rs index b36b020..ee68db0 100644 --- a/src/elements/callback_builder.rs +++ b/src/elements/callback_builder.rs @@ -3,6 +3,7 @@ use std::any::Any; use anyhow::Result; use super::ControllerButton; +use crate::prelude::*; macro_rules! callbacks { ($name:ident, $($cb:tt)*) => { @@ -26,7 +27,7 @@ macro_rules! callbacks { }; } -callbacks!(ClickCallbacks, Fn() -> Result<()> + Send + Sync); +callbacks!(ClickCallbacks, Fn(&mut GuiHandler) -> Result<()> + Send + Sync); callbacks!(SelectCallbacks, Fn(bool) -> anyhow::Result<()> + Send + Sync); callbacks!(CustomCallbacks, Fn(ControllerButton) -> anyhow::Result + Send + Sync); callbacks!(VecCallbacks, Fn(&dyn Any) -> Result<()> + Send + Sync); @@ -36,8 +37,8 @@ mod test { use super::*; use anyhow::Result; - fn normal_fn() -> impl Fn() -> Result<()> + Send + Sync { - || Ok(()) + fn normal_fn() -> impl Fn(&mut GuiHandler) -> Result<()> + Send + Sync { + |_| Ok(()) } #[test] @@ -47,7 +48,10 @@ mod test { impl Test { fn set_click_callbacks( &self, - _callbacks: Vec<(&str, Box Result<()> + Send + Sync>)>, + _callbacks: Vec<( + &str, + Box Result<()> + Send + Sync>, + )>, ) -> Result<()> { Ok(()) }