Mouse

Struct Mouse 

Source
pub struct Mouse<'a> { /* private fields */ }
Expand description

A struct for controlling a virtual mouse.

It holds a reference to a Device which is used to send the mouse commands.

Implementations§

Source§

impl<'a> Mouse<'a>

Source

pub const fn new(device: &'a Device) -> Self

Creates a new Mouse.

Source

pub fn click(&self, button: MouseButton, millis: u64)

Performs a click and release action with a specified button.

The button is pressed, held for millis milliseconds, and then released.

§Arguments
  • button - The MouseButton to click.
  • millis - The duration, in milliseconds, to hold the button down.
Source

pub fn move_absolute(&self, button: MouseButton, x: u16, y: u16, millis: u64)

Moves the mouse cursor to an absolute screen coordinate (x, y) with a simulated smooth movement.

The movement is broken down into smaller steps, with a delay between each step.

§Arguments
  • button - The MouseButton to hold down during the movement (e.g., for dragging). Use MouseButton::Release for no buttons.
  • x - The target horizontal coordinate.
  • y - The target vertical coordinate.
  • millis - The delay, in milliseconds, between each small movement step.
Source

pub fn move_relative(&self, button: MouseButton, x: i8, y: i8)

Moves the mouse cursor by a relative offset from its current position.

§Arguments
  • button - The MouseButton to hold down during the movement.
  • x - The horizontal offset. Positive values move right, negative move left.
  • y - The vertical offset. Positive values move down, negative move up.
Source

pub fn press(&self, button: MouseButton)

Presses and holds a specified mouse button.

This method only presses the button; you must call release() to release it.

§Arguments
  • button - The MouseButton to press.
Source

pub fn release(&self)

Releases any currently pressed mouse buttons.

This should be called after a press() action to release the button.

Source

pub fn wheel(&self, button: MouseButton, wheel: i8)

Scrolls the mouse wheel.

§Arguments
  • button - The MouseButton to hold down during the scroll.
  • wheel - The scroll amount. Positive values scroll up, negative values scroll down.

Auto Trait Implementations§

§

impl<'a> Freeze for Mouse<'a>

§

impl<'a> RefUnwindSafe for Mouse<'a>

§

impl<'a> !Send for Mouse<'a>

§

impl<'a> !Sync for Mouse<'a>

§

impl<'a> Unpin for Mouse<'a>

§

impl<'a> UnwindSafe for Mouse<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.