Struct GlobalCursor

Source
pub struct GlobalCursor;
Expand description

A global object that wraps the system cursor. Requires the cursor feature.

This object cannot be instanced. The methods should be used this way:

use native_windows_gui as nwg;
let (x,y) = nwg::GlobalCursor::position();

Implementations§

Source§

impl GlobalCursor

Source

pub fn position() -> (i32, i32)

Return the cursor position in the screen.

Examples found in repository?
examples/system_tray.rs (line 24)
23    fn show_menu(&self) {
24        let (x, y) = nwg::GlobalCursor::position();
25        self.tray_menu.popup(x, y);
26    }
Source

pub fn local_position<C: Into<ControlHandle>>( control: C, point: Option<(i32, i32)>, ) -> (i32, i32)

Return or map the cursor position relatively to a control. If point is None, Cursor::position is used.

Source

pub fn local_logical_position<C: Into<ControlHandle>>( control: C, point: Option<(i32, i32)>, ) -> (i32, i32)

Return or map the cursor position relatively to a control and convert to logical. If point is None, Cursor::position is used.

Source

pub fn set_position(x: i32, y: i32)

Set the cursor position in the screen.

Arguments: • x: The new x coordinates of the cursor • y: The new y coordinaets of the cursor

Source

pub fn set(cursor: &Cursor)

Set the cursor image. If your application must set the cursor while it is in a window, make sure the class cursor for the specified window’s class is set to NULL. If the class cursor is not NULL, the system restores the class cursor each time the mouse is moved.

Arguments: • cursor: The id identifying the cursor resource

Source

pub fn get() -> Option<Cursor>

Get the cursor image

Returns None if there is no cursor.

Source

pub fn set_capture(control: &ControlHandle)

Capture the mouse for a window-like control. Make sure to call Cursor::release to remove the capture. A control that has captured the mouse will receive mouse events even if the mouse is not hovering it.

Will panic if the control handle passed to the method is not a window or if the control is not yet initialized.

Arguments: • control: The control that will capture the mouse input

Source

pub fn release()

Release the cursor if it was captured with Cursor::set_capture

Source

pub fn capture() -> Option<ControlHandle>

Return the handle of the control that has captured the mouse. Return None if no control captured the cursor.

Arguments: • ui: The Ui holding the cursor resource

Source

pub fn dragging(control: &ControlHandle, point: Option<(i32, i32)>) -> bool

Captures the mouse and tracks its movement until the user releases the left button, presses the ESC key, or moves the mouse outside the drag rectangle around the specified point.

Return Ok(true) if the user did not execute the actions mentioned above or Ok(false) if it did.

Will panic if the control handle passed to the method is not a window or if the control is not yet initialized.

Arguments: • control: The control that will capture the mouse input • point: A point in screen coordinates where the dragging begins. If None, use the Cursor::position value.

    use native_windows_gui as nwg;
    fn dragging(c: &nwg::Window) {
        if nwg::GlobalCursor::dragging(&c.handle, None) {
            println!("DRAGGING!")
        }
    }

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.