Detector

Struct Detector 

Source
pub struct Detector<'a, T: Widget> {
    pub widget: Box<T>,
    pub on_tap: fn(widget: &'a mut T),
}
Expand description

Controller wrapping a widget to detect when it is tapped.

Fields§

§widget: Box<T>

Widget where the tap detection will be done.

§on_tap: fn(widget: &'a mut T)

Function called when the widget is tapped.

Implementations§

Source§

impl<'a, T: Widget> Detector<'a, T>

Source

pub fn new(widget: T, on_tap: fn(widget: &'a mut T)) -> Self

Creates a new detector for a widget calling on_tap when it is tapped.

Source

pub fn on_tap(&'static mut self)

Function to call when the widget is tapped.

Trait Implementations§

Source§

impl<'a, T: Debug + Widget> Debug for Detector<'a, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, T: Widget> DebugWidget for Detector<'a, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Should not be overridden
Source§

impl<'a, T: Widget + 'static> From<Detector<'a, T>> for Box<dyn Widget>

Source§

fn from(value: Detector<'a, T>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: Widget + 'static> ToAny for Detector<'a, T>

Source§

fn as_any(&self) -> &dyn Any

Converts the self value into a std::any::Any value. Read more
Source§

impl<'a, T: Widget + 'static> Widget for Detector<'a, T>

Source§

fn shape(&self, size: Option<Size>) -> Shape

Calls Widget::shape() on self.widget and returns the returned value of this function.

Auto Trait Implementations§

§

impl<'a, T> Freeze for Detector<'a, T>

§

impl<'a, T> RefUnwindSafe for Detector<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for Detector<'a, T>
where T: Send,

§

impl<'a, T> Sync for Detector<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for Detector<'a, T>

§

impl<'a, T> UnwindSafe for Detector<'a, T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.