I had an idea to add a component to a button from bevy ui to automaticaly emit event on hover and click. But for this to be effective i need the component to be generic like so: ```rust
#[derive(Component)]
pub struct OnHover<E: Event>(E)
but when i try to create the query in my system like so:
```rust
fn button_hover_system<E: Event>(
mut query: Query<
(&Interaction, OnHover<E>),
(Changed<Interaction>, With<Button>),
>,
mut event_writer: EventWriter<E>,
) {
for (interaction, hover) in &mut query {
match interaction {
Interaction::Hovered => event_writer.send(hover.0),
_ => (),
}
}
}
I get this error:
error[E0277]: the trait bound `OnHover<E>: WorldQuery` is not satisfied
--> beditor/src/widget/mod.rs:11:16
|
11 | mut query: Query<
| ________________^
12 | | (&Interaction, OnHover<E>),
13 | | (Changed<Interaction>, With<Button>),
14 | | >,
| |_____^ the trait `WorldQuery` is not implemented for `OnHover<E>`
|
= help: the following other types implement trait `WorldQuery`:
&'__w mut T
&T
()
(F0, F1)
(F0, F1, F2)
(F0, F1, F2, F3)
(F0, F1, F2, F3, F4)
(F0, F1, F2, F3, F4, F5)
and 54 others
= note: required for `(&Interaction, OnHover<E>)` to implement `WorldQuery`
note: required by a bound in `bevy::prelude::Query`
--> /home/adml/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/system/query.rs:276:37
|
276 | pub struct Query<'world, 'state, Q: WorldQuery, F: ReadOnlyWorldQuery = ()> {
| ^^^^^^^^^^ required by this bound in `bevy::prelude::Query`
Is that not possible right now ? Will it be in the future ? or am i doing something wrong ?