Struct Mouse

Source
pub struct Mouse { /* private fields */ }
Expand description

The Mouse struct that implements the MouseActions

§Example usage

use std::thread;
use std::time::Duration;

use mouce::{Mouse, MouseActions};

fn main() {
    let mouse_manager = Mouse::new();

    let mut x = 0;
    while x < 1920 {
        let _ = mouse_manager.move_to(x, 540);
        x += 1;
        thread::sleep(Duration::from_millis(2));
    }
}

Implementations§

Source§

impl Mouse

Source

pub fn new() -> Self

Trait Implementations§

Source§

impl Clone for Mouse

Source§

fn clone(&self) -> Mouse

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Mouse

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl MouseActions for Mouse

Source§

fn move_to(&self, x: i32, y: i32) -> Result<(), Error>

Move the mouse to the given x, y coordinates in logical pixel space Read more
Source§

fn move_relative(&self, x_offset: i32, y_offset: i32) -> Result<(), Error>

Move the mouse relative to the current position in logical pixel space Read more
Source§

fn get_position(&self) -> Result<(i32, i32), Error>

Get the current position of the mouse in logical pixel space Read more
Source§

fn press_button(&self, button: MouseButton) -> Result<(), Error>

Press down the given mouse button Read more
Source§

fn release_button(&self, button: MouseButton) -> Result<(), Error>

Release the given mouse button Read more
Source§

fn click_button(&self, button: MouseButton) -> Result<(), Error>

Click the given mouse button Read more
Source§

fn scroll_wheel( &self, direction: ScrollDirection, scroll_unit: ScrollUnit, distance: u32, ) -> Result<(), Error>

Scroll the mouse wheel towards to the given direction Read more
Source§

fn hook( &mut self, callback: Box<dyn Fn(&MouseEvent) + Send>, ) -> Result<CallbackId, Error>

Attach a callback function to mouse events Read more
Source§

fn unhook(&mut self, callback_id: CallbackId) -> Result<(), Error>

Remove the callback function with the given CallbackId
Source§

fn unhook_all(&mut self) -> Result<(), Error>

Remove all callback functions Read more

Auto Trait Implementations§

§

impl Freeze for Mouse

§

impl RefUnwindSafe for Mouse

§

impl Send for Mouse

§

impl !Sync for Mouse

§

impl Unpin for Mouse

§

impl UnwindSafe for Mouse

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.