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§
Sourcefn is_focused(&self) -> bool
fn is_focused(&self) -> bool
Whether this element currently has focus.
Sourcefn set_focused(&mut self, focused: bool)
fn set_focused(&mut self, focused: bool)
Set focus state for this element.
Sourcefn contains_point(&self, x: f32, y: f32) -> bool
fn contains_point(&self, x: f32, y: f32) -> bool
Hit-test: does this element contain the given logical point?
Provided Methods§
Sourcefn handle_mouse_click(&mut self, event: &MouseClickEvent) -> EventResult
fn handle_mouse_click(&mut self, event: &MouseClickEvent) -> EventResult
Handle a mouse click event. Returns Handled if the event was consumed.
Sourcefn handle_keyboard(&mut self, event: &KeyboardEvent) -> EventResult
fn handle_keyboard(&mut self, event: &KeyboardEvent) -> EventResult
Handle a keyboard event. Returns Handled if the event was consumed.
Sourcefn handle_mouse_move(&mut self, event: &MouseMoveEvent) -> EventResult
fn handle_mouse_move(&mut self, event: &MouseMoveEvent) -> EventResult
Handle a mouse-move event.
Sourcefn handle_scroll(&mut self, event: &ScrollEvent) -> EventResult
fn handle_scroll(&mut self, event: &ScrollEvent) -> EventResult
Handle a scroll event.