pub trait WidgetQuery<'w, 's> {
type WidgetView<'a>
where Self: 'a;
// Required methods
fn find_by_id<'a>(
&'a mut self,
target_id: &str,
) -> Option<Self::WidgetView<'a>>;
fn find_by_entity<'a>(
&'a mut self,
entity: Entity,
) -> Option<Self::WidgetView<'a>>;
fn find_by_class(&self, target_class: &str) -> Vec<Entity>;
fn get_components<'a>(
&'a mut self,
entity: Entity,
) -> Option<Self::WidgetView<'a>>;
// Provided methods
fn get_by_id<F>(&mut self, id: &str, f: F)
where F: for<'a> FnOnce(&mut Self::WidgetView<'a>) { ... }
fn get_by_entity<F>(&mut self, entity: Entity, f: F)
where F: for<'a> FnOnce(&mut Self::WidgetView<'a>) { ... }
fn get_by_class<F>(&mut self, class: &str, f: F)
where F: for<'a> FnMut(&mut Self::WidgetView<'a>) { ... }
}Expand description
Trait used for widgets system param.
Required Associated Types§
Sourcetype WidgetView<'a>
where
Self: 'a
type WidgetView<'a> where Self: 'a
The specific view struct this query returns (Ex, ButtonWidget, TextWidget).
Required Methods§
Sourcefn find_by_id<'a>(&'a mut self, target_id: &str) -> Option<Self::WidgetView<'a>>
fn find_by_id<'a>(&'a mut self, target_id: &str) -> Option<Self::WidgetView<'a>>
Method to find widget by ID.
Sourcefn find_by_entity<'a>(
&'a mut self,
entity: Entity,
) -> Option<Self::WidgetView<'a>>
fn find_by_entity<'a>( &'a mut self, entity: Entity, ) -> Option<Self::WidgetView<'a>>
Method to find widget by Entity.
Sourcefn find_by_class(&self, target_class: &str) -> Vec<Entity>
fn find_by_class(&self, target_class: &str) -> Vec<Entity>
Method to find entities that match with provided classes.
Sourcefn get_components<'a>(
&'a mut self,
entity: Entity,
) -> Option<Self::WidgetView<'a>>
fn get_components<'a>( &'a mut self, entity: Entity, ) -> Option<Self::WidgetView<'a>>
Get related components of an entity.
Provided Methods§
Sourcefn get_by_id<F>(&mut self, id: &str, f: F)where
F: for<'a> FnOnce(&mut Self::WidgetView<'a>),
fn get_by_id<F>(&mut self, id: &str, f: F)where
F: for<'a> FnOnce(&mut Self::WidgetView<'a>),
Get the widget and executes a closure on a widget found by its ID.
Sourcefn get_by_entity<F>(&mut self, entity: Entity, f: F)where
F: for<'a> FnOnce(&mut Self::WidgetView<'a>),
fn get_by_entity<F>(&mut self, entity: Entity, f: F)where
F: for<'a> FnOnce(&mut Self::WidgetView<'a>),
Get the widget and executes a closure on a widget found by its Entity.
Sourcefn get_by_class<F>(&mut self, class: &str, f: F)where
F: for<'a> FnMut(&mut Self::WidgetView<'a>),
fn get_by_class<F>(&mut self, class: &str, f: F)where
F: for<'a> FnMut(&mut Self::WidgetView<'a>),
Executes a closure on every widget that matches the specified class.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.