Trait primitives::prelude::InputMouse
source · [−]pub trait InputMouse {
Show 29 methods
fn x(&self) -> i32;
fn y(&self) -> i32;
fn relative_x(&self) -> f32;
fn relative_y(&self) -> f32;
fn relative_centralised_x(&self) -> f32;
fn relative_centralised_y(&self) -> f32;
fn is_within_bounds(&self) -> bool;
fn is_moving(&self) -> bool;
fn is_visible(&self) -> bool;
fn set_visible(&self, val: bool);
fn scroll(&self) -> i32;
fn cursor(&self) -> MouseCursor;
fn set_cursor(&self, val: MouseCursor) -> MouseCursor;
fn get_delta_x(&self, as_time: Option<bool>) -> i32;
fn get_delta_y(&self, as_time: Option<bool>) -> i32;
fn get_speed(&self, as_time: Option<bool>) -> i32;
fn get_delta_scroll(&self, as_time: Option<bool>) -> i32;
fn get_still_duration(&self, as_time: Option<bool>) -> i32;
fn is_button_double_click(
&self,
kind: Option<MouseButton>,
delay: Option<i32>
) -> bool;
fn is_button_drag(
&self,
kind: Option<MouseButton>,
delay: Option<i32>
) -> bool;
fn is_button_down(&self, kind: Option<MouseButton>) -> bool;
fn is_button_press(&self, kind: Option<MouseButton>) -> bool;
fn is_button_release(&self, kind: Option<MouseButton>) -> bool;
fn get_button_down_duration(
&self,
kind: Option<MouseButton>,
as_time: Option<bool>,
is_previous: Option<bool>
) -> i32;
fn get_button_up_duration(
&self,
kind: Option<MouseButton>,
as_time: Option<bool>,
is_previous: Option<bool>
) -> i32;
fn get_button_drag_width(&self, kind: Option<MouseButton>) -> i32;
fn get_button_drag_height(&self, kind: Option<MouseButton>) -> i32;
fn get_button_last_clicked_x(&self, kind: Option<MouseButton>) -> i32;
fn get_button_last_clicked_y(&self, kind: Option<MouseButton>) -> i32;
}
Expand description
The InputMouse should be implemented by objects wishing to act as virtual mouse controllers.
Screen bounds are based on Factory::width & Factory::height.
Required Methods
fn relative_x(&self) -> f32
fn relative_x(&self) -> f32
The horizontal position of the mouse relative to screen width. Range 0…1.
fn relative_y(&self) -> f32
fn relative_y(&self) -> f32
The vertical position of the mouse relative to screen height. Range 0…1.
fn relative_centralised_x(&self) -> f32
fn relative_centralised_x(&self) -> f32
The horizontal position of the mouse relative to screen width and offset to screen centre. Range -1…1.
fn relative_centralised_y(&self) -> f32
fn relative_centralised_y(&self) -> f32
The vertical position of the mouse relative to screen height and offset to screen centre. Range -1…1.
fn is_within_bounds(&self) -> bool
fn is_within_bounds(&self) -> bool
Returns true if the mouse position is within the bounding rectangle (factory width x factory height).
Returns true if the mouse position is different to the previous update’s position.
fn is_visible(&self) -> bool
fn is_visible(&self) -> bool
Get the visibility of the mouse cursor.
fn set_visible(&self, val: bool)
fn set_visible(&self, val: bool)
Specify the visibility of the mouse cursor. If true the cursor will be displayed, if false the cursor is hidden.
fn cursor(&self) -> MouseCursor
fn cursor(&self) -> MouseCursor
The current cursor type.
fn set_cursor(&self, val: MouseCursor) -> MouseCursor
fn set_cursor(&self, val: MouseCursor) -> MouseCursor
Set the cursor type.
fn get_delta_x(&self, as_time: Option<bool>) -> i32
fn get_delta_x(&self, as_time: Option<bool>) -> i32
The horizontal velocity of the mouse position.
Arguments
as_time
- If true then returns the velocity as pixels per second (extrapolated from the previous update), else returns velocity as pixels moved in previous update. (optional, default: true)
Return: The horizontal velocity of the mouse.
fn get_delta_y(&self, as_time: Option<bool>) -> i32
fn get_delta_y(&self, as_time: Option<bool>) -> i32
The vertical velocity of the mouse position.
Arguments
as_time
- If true then returns the velocity as pixels per second (extrapolated from the previous update), else returns velocity as pixels moved in previous update. (optional, default: true)
Return: The vertical velocity of the mouse.
The velocity of the mouse.
Arguments
as_time
- If true then returns the velocity as pixels per second (extrapolated from the previous update), else returns velocity as pixels moved in previous update. (optional, default: true)
Return: The velocity of the mouse.
fn get_delta_scroll(&self, as_time: Option<bool>) -> i32
fn get_delta_scroll(&self, as_time: Option<bool>) -> i32
The velocity of scrolling.
Arguments
as_time
- If true then returns the velocity as pixels per second (extrapolated from the previous update), else returns velocity as scroll moved in previous update. (optional, default: true)
Return: The scroll velocity of the mouse.
fn get_still_duration(&self, as_time: Option<bool>) -> i32
fn get_still_duration(&self, as_time: Option<bool>) -> i32
Determine how long the mouse has been still.
Arguments
as_time
- If true then returns duration as milliseconds, else returns duration as frame updates. (optional, default: true)
Return: Returns the duration the mouse has been still.
Determine if a specific mouse button was clicked twice (within the defined time).
Arguments
kind
- The mouse button. (optional)delay
- The time within which the mouse button must be clicked twice. (optional, default: 100)
Return: Returns true if the mouse button was clicked twice (within the defined time).
Determine if the mouse is being dragged with a specific mouse button down (for at least the defined delay).
Arguments
kind
- The mouse button. (optional)delay
- The time which, if exceeded, assumes the mouse is being dragged. (optional, default: 100)
Return: Returns true if the mouse button was down for a duration exceeding delay.
Determine if a specific mouse button is currently down.
Arguments
kind
- The mouse button. (optional)
Return: Returns true is the mouse button is currently down, false otherwise.
Determine if a specific mouse button was pressed in the current update frame.
Arguments
A press is defined as a new down - i.e. was up previous frame, and is down this frame.
kind
- The mouse button. (optional)
Return: Returns true is the mouse button was pressed in the current update, false otherwise.
Determine if a specific mouse button was released in the current update. A release is defined as a new up - i.e. was down previous frame, and is up this frame.
Arguments
kind
- The mouse button. (optional)
Return: Returns true is the mouse button was released in the current update, false otherwise.
Determine the duration a specific mouse button is down.
Arguments
kind
- The mouse button. (optional)as_time
- If true then returns duration as milliseconds, else returns duration as frame updates. (optional, default: true)- `is_previous If true then returns the previous duration down (the time held prior to the most recent release). (optional, default: false)
Return: The duration a specific mouse button is down.
Determine the duration a specific mouse button is up.
Arguments
kind
- The mouse button. (optional)as_time
- If true then returns duration as milliseconds, else returns duration as frame updates. (optional, default: true)is_previous
- If true then returns the previous duration up (the time unused prior to the most recent press). (optional, default: false)
Return: The duration a specific mouse button is up.
Determine the horizontal movement of the mouse since a specific mouse button was pressed.
Arguments
kind
- The mouse button. (optional)
Return: The horizontal movement of the mouse.
Determine the vertical movement of the mouse since a specific mouse button was pressed.
Arguments
kind
- The mouse button. (optional)
Return: The vertical movement of the mouse.
Determine the horizontal position of the mouse when a specific mouse button was last clicked.
Arguments
kind
- The mouse button. (optional)
Return: The horizontal position of the mouse.
Determine the vertical position of the mouse when a specific mouse button was last clicked.
Arguments
kind
- The mouse button. (optional)
Return: The vertical position of the mouse.