pub struct MouseEvent {
pub kind: MouseEventKind,
pub column: u16,
pub row: u16,
pub modifiers: KeyModifiers,
}Expand description
A mouse event
§Example
match event {
Event::Mouse(mouse) => {
if mouse.is_left_click() {
println!("Left clicked at ({}, {})", mouse.column, mouse.row);
} else if mouse.is_scroll_up() {
println!("Scrolled up");
}
}
_ => {}
}Fields§
§kind: MouseEventKindThe kind of mouse event
column: u16Column (x coordinate)
row: u16Row (y coordinate)
modifiers: KeyModifiersKey modifiers held during the event
Implementations§
Source§impl MouseEvent
impl MouseEvent
Sourcepub fn new(
kind: MouseEventKind,
column: u16,
row: u16,
modifiers: KeyModifiers,
) -> MouseEvent
pub fn new( kind: MouseEventKind, column: u16, row: u16, modifiers: KeyModifiers, ) -> MouseEvent
Create a new mouse event
Sourcepub fn is_left_click(&self) -> bool
pub fn is_left_click(&self) -> bool
Check if this is a left button click (button down event)
Sourcepub fn is_right_click(&self) -> bool
pub fn is_right_click(&self) -> bool
Check if this is a right button click (button down event)
Sourcepub fn is_middle_click(&self) -> bool
pub fn is_middle_click(&self) -> bool
Check if this is a middle button click (button down event)
Sourcepub fn is_release(&self) -> bool
pub fn is_release(&self) -> bool
Check if this is a button release event
Sourcepub fn is_left_drag(&self) -> bool
pub fn is_left_drag(&self) -> bool
Check if this is a left button drag
Sourcepub fn is_right_drag(&self) -> bool
pub fn is_right_drag(&self) -> bool
Check if this is a right button drag
Sourcepub fn is_middle_drag(&self) -> bool
pub fn is_middle_drag(&self) -> bool
Check if this is a middle button drag
Sourcepub fn is_scroll_up(&self) -> bool
pub fn is_scroll_up(&self) -> bool
Check if this is a scroll up event
Sourcepub fn is_scroll_down(&self) -> bool
pub fn is_scroll_down(&self) -> bool
Check if this is a scroll down event
Sourcepub fn is_scroll_left(&self) -> bool
pub fn is_scroll_left(&self) -> bool
Check if this is a scroll left event
Sourcepub fn is_scroll_right(&self) -> bool
pub fn is_scroll_right(&self) -> bool
Check if this is a scroll right event
Get the button involved in this event, if any
Sourcepub fn is_within(&self, x: u16, y: u16, width: u16, height: u16) -> bool
pub fn is_within(&self, x: u16, y: u16, width: u16, height: u16) -> bool
Check if the mouse event occurred within a rectangular area
§Example
let (x, y, width, height) = (10, 10, 20, 10);
if mouse_event.is_within(x, y, width, height) {
// Mouse event is within the rectangle
}Sourcepub fn is_at(&self, column: u16, row: u16) -> bool
pub fn is_at(&self, column: u16, row: u16) -> bool
Check if the mouse event occurred at a specific position
Sourcepub fn has_modifier(&self, modifier: KeyModifiers) -> bool
pub fn has_modifier(&self, modifier: KeyModifiers) -> bool
Check if a modifier key was held during the event
Sourcepub fn has_modifiers(&self) -> bool
pub fn has_modifiers(&self) -> bool
Check if this mouse event has any modifiers
Sourcepub fn no_modifiers(&self) -> bool
pub fn no_modifiers(&self) -> bool
Check if this mouse event has no modifiers
Trait Implementations§
Source§impl Clone for MouseEvent
impl Clone for MouseEvent
Source§fn clone(&self) -> MouseEvent
fn clone(&self) -> MouseEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more