pub struct MouseState {
    pub x: i32,
    pub y: i32,
    pub virtual_x: i32,
    pub virtual_y: i32,
}
Expand description

An input handler that tracks the position of the mouse.

It provides physical and virtual coordinates.

  • Virtual coordinates (virtual_x and virtual_y) are as reported by the OS, which means that they originate from the upper left corner and account for DPI. You don’t want this very often, but if you want to match the OS coordinates for some reason, this is it.
  • Physical coordinates (x and y) match the pixels in the image. This is usually what you want.

Fields

x: i32

The x position from the lower-left corner, measured in physical pixels. This should always correspond to the column of the pixel in the image.

y: i32

The y position from the lower-left corner, measured in physical pixels. This should always correspond to the row of the pixel in the image.

virtual_x: i32

The x position from the upper-left corner as reported by the OS, measured in virtual pixels.

virtual_y: i32

The y position from the upper-left corner as reported by the OS, measured in virtual pixels.

Implementations

Create a MouseState. For use with the state method.

Handle input for the mouse. For use with the input method.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.