[][src]Struct pixel_canvas::input::MouseState

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

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

impl MouseState[src]

pub fn new() -> Self[src]

Create a MouseState. For use with the state method.

pub fn handle_input(
    info: &CanvasInfo,
    mouse: &mut MouseState,
    event: &Event<'_, ()>
) -> bool
[src]

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

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.