pub struct MouseWindowLocation { /* private fields */ }Expand description
Mouse’s location within a window, in points.
The coordinate system has its origin at the upper-left corner of the window. The position is reported in logical points, not physical pixels.
§Examples
use app_window::input::mouse::Mouse;
let mouse = Mouse::coalesced().await;
if let Some(location) = mouse.window_pos() {
println!("Mouse at ({}, {})", location.pos_x(), location.pos_y());
println!("Window size: {}x{}", location.window_width(), location.window_height());
}Implementations§
Source§impl MouseWindowLocation
impl MouseWindowLocation
Sourcepub fn pos_x(&self) -> f64
pub fn pos_x(&self) -> f64
Returns the X coordinate of the mouse position within the window.
The X coordinate is measured from the left edge of the window.
§Examples
if let Some(location) = mouse.window_pos() {
let x = location.pos_x();
println!("Mouse X: {}", x);
}Sourcepub fn pos_y(&self) -> f64
pub fn pos_y(&self) -> f64
Returns the Y coordinate of the mouse position within the window.
The Y coordinate is measured from the top edge of the window.
§Examples
if let Some(location) = mouse.window_pos() {
let y = location.pos_y();
println!("Mouse Y: {}", y);
}Sourcepub fn window_width(&self) -> f64
pub fn window_width(&self) -> f64
Returns the width of the window containing the mouse.
§Examples
if let Some(location) = mouse.window_pos() {
let width = location.window_width();
println!("Window width: {}", width);
}Sourcepub fn window_height(&self) -> f64
pub fn window_height(&self) -> f64
Returns the height of the window containing the mouse.
§Examples
if let Some(location) = mouse.window_pos() {
let height = location.window_height();
println!("Window height: {}", height);
}Trait Implementations§
Source§impl Clone for MouseWindowLocation
impl Clone for MouseWindowLocation
Source§fn clone(&self) -> MouseWindowLocation
fn clone(&self) -> MouseWindowLocation
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for MouseWindowLocation
Auto Trait Implementations§
impl !Sync for MouseWindowLocation
impl Freeze for MouseWindowLocation
impl RefUnwindSafe for MouseWindowLocation
impl Send for MouseWindowLocation
impl Unpin for MouseWindowLocation
impl UnsafeUnpin for MouseWindowLocation
impl UnwindSafe for MouseWindowLocation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.