pub struct EventHandler {
pub event: &'static str,
pub callback: Callback,
}Expand description
An event handler attached to a UI element.
Fields§
§event: &'static strThe event name this handler listens to (“click”, “input”, …).
callback: CallbackThe callback invoked when the event fires.
Implementations§
Source§impl EventHandler
impl EventHandler
Sourcepub fn onclick<F: Fn(BubbaEvent) + Send + Sync + 'static>(f: F) -> Self
pub fn onclick<F: Fn(BubbaEvent) + Send + Sync + 'static>(f: F) -> Self
Convenience: create an onclick handler.
Sourcepub fn oninput<F: Fn(BubbaEvent) + Send + Sync + 'static>(f: F) -> Self
pub fn oninput<F: Fn(BubbaEvent) + Send + Sync + 'static>(f: F) -> Self
Convenience: create an oninput handler.
Sourcepub fn onkeypress<F: Fn(BubbaEvent) + Send + Sync + 'static>(f: F) -> Self
pub fn onkeypress<F: Fn(BubbaEvent) + Send + Sync + 'static>(f: F) -> Self
Convenience: create an onkeypress handler.
Sourcepub fn onfocus<F: Fn(BubbaEvent) + Send + Sync + 'static>(f: F) -> Self
pub fn onfocus<F: Fn(BubbaEvent) + Send + Sync + 'static>(f: F) -> Self
Convenience: create an onfocus handler.
Sourcepub fn onblur<F: Fn(BubbaEvent) + Send + Sync + 'static>(f: F) -> Self
pub fn onblur<F: Fn(BubbaEvent) + Send + Sync + 'static>(f: F) -> Self
Convenience: create an onblur handler.
Sourcepub fn dispatch(&self, event: BubbaEvent)
pub fn dispatch(&self, event: BubbaEvent)
Dispatch this handler with a given event payload.
Trait Implementations§
Source§impl Clone for EventHandler
impl Clone for EventHandler
Source§fn clone(&self) -> EventHandler
fn clone(&self) -> EventHandler
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for EventHandler
impl !RefUnwindSafe for EventHandler
impl Send for EventHandler
impl Sync for EventHandler
impl Unpin for EventHandler
impl UnsafeUnpin for EventHandler
impl !UnwindSafe for EventHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more