pub trait MouseControllable {
// Required methods
fn mouse_move_to(&mut self, x: i32, y: i32);
fn mouse_move_relative(&mut self, x: i32, y: i32);
fn mouse_down(&mut self, button: MouseButton);
fn mouse_up(&mut self, button: MouseButton);
fn mouse_click(&mut self, button: MouseButton);
fn mouse_scroll_x(&mut self, length: i32);
fn mouse_scroll_y(&mut self, length: i32);
}Expand description
Representing an interface and a set of mouse functions every operating system implementation should implement.
Required Methods§
Sourcefn mouse_move_to(&mut self, x: i32, y: i32)
fn mouse_move_to(&mut self, x: i32, y: i32)
Lets the mouse cursor move to the specified x and y coordinates.
The topleft corner of your monitor screen is x=0 y=0. Move the cursor down the screen by increasing the y and to the right by increasing x coordinate.
§Example
use noct::*;
let mut noct = Noct::new();
noct.mouse_move_to(500, 200);Sourcefn mouse_move_relative(&mut self, x: i32, y: i32)
fn mouse_move_relative(&mut self, x: i32, y: i32)
Lets the mouse cursor move the specified amount in the x and y direction.
The amount specified in the x and y parameters are added to the
current location of the mouse cursor. A positive x values lets
the mouse cursor move an amount of x pixels to the right. A negative
value for x lets the mouse cursor go to the left. A positive value
of y
lets the mouse cursor go down, a negative one lets the mouse cursor go
up.
§Example
use noct::*;
let mut noct = Noct::new();
noct.mouse_move_relative(100, 100);Sourcefn mouse_down(&mut self, button: MouseButton)
fn mouse_down(&mut self, button: MouseButton)
Push down one of the mouse buttons
Push down the mouse button specified by the parameter button of
type MouseButton
and holds it until it is released by
mouse_up.
Calls to [mouse_move_to](trait.MouseControllable.html#tymethod.
mouse_move_to) or
[mouse_move_relative](trait.MouseControllable.html#tymethod.
mouse_move_relative)
will work like expected and will e.g. drag widgets or highlight text.
§Example
use noct::*;
let mut noct = Noct::new();
noct.mouse_down(MouseButton::Left);Sourcefn mouse_up(&mut self, button: MouseButton)
fn mouse_up(&mut self, button: MouseButton)
Lift up a pushed down mouse button
Lift up a previously pushed down button (by invoking mouse_down). If the button was not pushed down or consecutive calls without invoking mouse_down will emit lift up events. It depends on the operating system whats actually happening – my guess is it will just get ignored.
§Example
use noct::*;
let mut noct = Noct::new();
noct.mouse_up(MouseButton::Right);Sourcefn mouse_click(&mut self, button: MouseButton)
fn mouse_click(&mut self, button: MouseButton)
Click a mouse button
it’s esentially just a consecutive invokation of mouse_down followed by a mouse_up. Just for convenience.
§Example
use noct::*;
let mut noct = Noct::new();
noct.mouse_click(MouseButton::Right);Sourcefn mouse_scroll_x(&mut self, length: i32)
fn mouse_scroll_x(&mut self, length: i32)
Scroll the mouse (wheel) left or right
Positive numbers for length lets the mouse wheel scroll to the right
and negative ones to the left. The value that is specified translates
to lines defined by the operating system and is essentially one 15°
(click)rotation on the mouse wheel. How many lines it moves depends
on the current setting in the operating system.
§Example
use noct::*;
let mut noct = Noct::new();
noct.mouse_scroll_x(2);Sourcefn mouse_scroll_y(&mut self, length: i32)
fn mouse_scroll_y(&mut self, length: i32)
Scroll the mouse (wheel) up or down
Positive numbers for length lets the mouse wheel scroll down
and negative ones up. The value that is specified translates
to lines defined by the operating system and is essentially one 15°
(click)rotation on the mouse wheel. How many lines it moves depends
on the current setting in the operating system.
§Example
use noct::*;
let mut noct = Noct::new();
noct.mouse_scroll_y(2);