pub struct MouseMsg {
pub x: u16,
pub y: u16,
pub shift: bool,
pub alt: bool,
pub ctrl: bool,
pub action: MouseAction,
pub button: MouseButton,
}Expand description
Mouse event message.
MouseMsg is sent to the program’s update function when mouse activity occurs.
Note: Mouse events must be enabled using Program::with_mouse_cell_motion()
or Program::with_mouse_all_motion().
§Example
use bubbletea::{MouseMsg, MouseButton, MouseAction};
fn handle_mouse(mouse: MouseMsg) {
if mouse.button == MouseButton::Left && mouse.action == MouseAction::Press {
println!("Left click at ({}, {})", mouse.x, mouse.y);
}
}Fields§
§x: u16X coordinate (column), 0-indexed.
y: u16Y coordinate (row), 0-indexed.
shift: boolWhether Shift was held.
alt: boolWhether Alt was held.
ctrl: boolWhether Ctrl was held.
action: MouseActionThe action that occurred.
The button involved.
Implementations§
Trait Implementations§
impl Copy for MouseMsg
impl Eq for MouseMsg
impl StructuralPartialEq for MouseMsg
Auto Trait Implementations§
impl Freeze for MouseMsg
impl RefUnwindSafe for MouseMsg
impl Send for MouseMsg
impl Sync for MouseMsg
impl Unpin for MouseMsg
impl UnwindSafe for MouseMsg
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