on_custom_attribs Box → Rc
This commit is contained in:
@@ -8,9 +8,9 @@ use glam::Vec2;
|
|||||||
use wgui::{
|
use wgui::{
|
||||||
assets::AssetPath,
|
assets::AssetPath,
|
||||||
components::{
|
components::{
|
||||||
Component,
|
|
||||||
button::{ButtonClickCallback, ComponentButton},
|
button::{ButtonClickCallback, ComponentButton},
|
||||||
checkbox::ComponentCheckbox,
|
checkbox::ComponentCheckbox,
|
||||||
|
Component,
|
||||||
},
|
},
|
||||||
drawing::Color,
|
drawing::Color,
|
||||||
event::StyleSetRequest,
|
event::StyleSetRequest,
|
||||||
@@ -90,7 +90,7 @@ impl TestbedGeneric {
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
let extra = ParseDocumentExtra {
|
let extra = ParseDocumentExtra {
|
||||||
on_custom_attribs: Some(Box::new(move |par| {
|
on_custom_attribs: Some(Rc::new(move |par| {
|
||||||
let Some(my_custom_value) = par.get_value("_my_custom") else {
|
let Some(my_custom_value) = par.get_value("_my_custom") else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1069,9 +1069,9 @@ impl CustomAttribsInfoOwned {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type OnCustomAttribsFunc = Box<dyn Fn(CustomAttribsInfo)>;
|
pub type OnCustomAttribsFunc = Rc<dyn Fn(CustomAttribsInfo)>;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default, Clone)]
|
||||||
pub struct ParseDocumentExtra {
|
pub struct ParseDocumentExtra {
|
||||||
pub on_custom_attribs: Option<OnCustomAttribsFunc>, // all attributes with '_' character prepended
|
pub on_custom_attribs: Option<OnCustomAttribsFunc>, // all attributes with '_' character prepended
|
||||||
pub dev_mode: bool,
|
pub dev_mode: bool,
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ impl<S: 'static> GuiPanel<S> {
|
|||||||
AssetPath::FileOrBuiltIn(path)
|
AssetPath::FileOrBuiltIn(path)
|
||||||
},
|
},
|
||||||
extra: wgui::parser::ParseDocumentExtra {
|
extra: wgui::parser::ParseDocumentExtra {
|
||||||
on_custom_attribs: Some(Box::new({
|
on_custom_attribs: Some(Rc::new({
|
||||||
let custom_elems = custom_elems.clone();
|
let custom_elems = custom_elems.clone();
|
||||||
move |attribs| {
|
move |attribs| {
|
||||||
custom_elems.borrow_mut().push(attribs.to_owned());
|
custom_elems.borrow_mut().push(attribs.to_owned());
|
||||||
|
|||||||
Reference in New Issue
Block a user