Trait InputMouse

Source
pub trait InputMouse {
Show 29 methods // Required 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§

Source

fn x(&self) -> i32

The horizontal component of the mouse position.

Source

fn y(&self) -> i32

The vertical component of the mouse position.

Source

fn relative_x(&self) -> f32

The horizontal position of the mouse relative to screen width. Range 0…1.

Source

fn relative_y(&self) -> f32

The vertical position of the mouse relative to screen height. Range 0…1.

Source

fn relative_centralised_x(&self) -> f32

The horizontal position of the mouse relative to screen width and offset to screen centre. Range -1…1.

Source

fn relative_centralised_y(&self) -> f32

The vertical position of the mouse relative to screen height and offset to screen centre. Range -1…1.

Source

fn is_within_bounds(&self) -> bool

Returns true if the mouse position is within the bounding rectangle (factory width x factory height).

Source

fn is_moving(&self) -> bool

Returns true if the mouse position is different to the previous update’s position.

Source

fn is_visible(&self) -> bool

Get the visibility of the mouse cursor.

Source

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.

Source

fn scroll(&self) -> i32

The current scroll position. Starts at 0. Range -infinity…infinity.

Source

fn cursor(&self) -> MouseCursor

The current cursor type.

Source

fn set_cursor(&self, val: MouseCursor) -> MouseCursor

Set the cursor type.

Source

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.

Source

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.

Source

fn get_speed(&self, as_time: Option<bool>) -> i32

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.

Source

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.

Source

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.

Source

fn is_button_double_click( &self, kind: Option<MouseButton>, delay: Option<i32>, ) -> bool

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).

Source

fn is_button_drag(&self, kind: Option<MouseButton>, delay: Option<i32>) -> bool

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.

Source

fn is_button_down(&self, kind: Option<MouseButton>) -> bool

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.

Source

fn is_button_press(&self, kind: Option<MouseButton>) -> bool

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.

Source

fn is_button_release(&self, kind: Option<MouseButton>) -> bool

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.

Source

fn get_button_down_duration( &self, kind: Option<MouseButton>, as_time: Option<bool>, is_previous: Option<bool>, ) -> i32

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.

Source

fn get_button_up_duration( &self, kind: Option<MouseButton>, as_time: Option<bool>, is_previous: Option<bool>, ) -> i32

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.

Source

fn get_button_drag_width(&self, kind: Option<MouseButton>) -> i32

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.

Source

fn get_button_drag_height(&self, kind: Option<MouseButton>) -> i32

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.

Source

fn get_button_last_clicked_x(&self, kind: Option<MouseButton>) -> i32

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.

Source

fn get_button_last_clicked_y(&self, kind: Option<MouseButton>) -> i32

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.

Implementors§