use crate::prelude::*;
#[derive(Declare)]
pub struct PointerPressed {
#[declare(skip, builtin)]
pointer_pressed: bool,
}
impl PointerPressed {
#[inline]
pub fn pointer_pressed(&self) -> bool { self.pointer_pressed }
}
impl ComposeChild for PointerPressed {
type Child = Widget;
fn compose_child(this: State<Self>, child: Self::Child) -> Widget {
widget! {
states { this: this.into_writable()}
DynWidget {
dyns: child,
on_pointer_down: move|_| this.pointer_pressed = true,
on_pointer_up: move |_| this.pointer_pressed = false,
}
}
}
}