Skip to main content

EventHandler

Trait EventHandler 

Source
pub trait EventHandler {
    // Required methods
    fn is_focused(&self) -> bool;
    fn set_focused(&mut self, focused: bool);
    fn contains_point(&self, x: f32, y: f32) -> bool;

    // Provided methods
    fn handle_mouse_click(&mut self, event: &MouseClickEvent) -> EventResult { ... }
    fn handle_keyboard(&mut self, event: &KeyboardEvent) -> EventResult { ... }
    fn handle_mouse_move(&mut self, event: &MouseMoveEvent) -> EventResult { ... }
    fn handle_scroll(&mut self, event: &ScrollEvent) -> EventResult { ... }
}
Expand description

Trait for elements that can receive and handle input events.

Required Methods§

Source

fn is_focused(&self) -> bool

Whether this element currently has focus.

Source

fn set_focused(&mut self, focused: bool)

Set focus state for this element.

Source

fn contains_point(&self, x: f32, y: f32) -> bool

Hit-test: does this element contain the given logical point?

Provided Methods§

Source

fn handle_mouse_click(&mut self, event: &MouseClickEvent) -> EventResult

Handle a mouse click event. Returns Handled if the event was consumed.

Source

fn handle_keyboard(&mut self, event: &KeyboardEvent) -> EventResult

Handle a keyboard event. Returns Handled if the event was consumed.

Source

fn handle_mouse_move(&mut self, event: &MouseMoveEvent) -> EventResult

Handle a mouse-move event.

Source

fn handle_scroll(&mut self, event: &ScrollEvent) -> EventResult

Handle a scroll event.

Implementors§