pub struct Mouse { /* private fields */ }
Expand description
The IMouse interface represents the virtual machine’s mouse.
Reference to the official documentation:
Implementations§
Source§impl Mouse
impl Mouse
Sourcepub fn put_mouse_event(
&self,
dx: i32,
dy: i32,
dz: i32,
dw: i32,
button_state: MouseButtonState,
) -> Result<(), VboxError>
pub fn put_mouse_event( &self, dx: i32, dy: i32, dz: i32, dw: i32, button_state: MouseButtonState, ) -> Result<(), VboxError>
Initiates a mouse event using relative pointer movements along x and y axis.
§Arguments
dx
- Amount of pixels the mouse should move to the right. Negative values move the mouse to the left.dy
- Amount of pixels the mouse should move downwards. Negative values move the mouse upwards.dz
- Amount of mouse wheel moves. Positive values describe clockwise wheel rotations, negative values describe counterclockwise rotations.dw
- Amount of horizontal mouse wheel moves. Positive values describe a movement to the left, negative values describe a movement to the right.button_state
- The current state of mouse buttons.
§Returns
Returns Ok(()) success, or a VboxError
on failure.
§Example
use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::{MouseButtonState, SessionType};
let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();
let console = session.get_console().unwrap();
let mouse = console.get_mouse().unwrap();
mouse.put_mouse_event(1,1,1,1,MouseButtonState::Left).unwrap();
Sourcepub fn put_mouse_event_absolute(
&self,
x: i32,
y: i32,
dz: i32,
dw: i32,
button_state: MouseButtonState,
) -> Result<(), VboxError>
pub fn put_mouse_event_absolute( &self, x: i32, y: i32, dz: i32, dw: i32, button_state: MouseButtonState, ) -> Result<(), VboxError>
Positions the mouse pointer using absolute x and y coordinates.
§Arguments
x
- X coordinate of the pointer in pixels, starting from 1.y
- Y coordinate of the pointer in pixels, starting from 1.dz
- Amount of mouse wheel moves. Positive values describe clockwise wheel rotations, negative values describe counterclockwise rotations.dw
- Amount of horizontal mouse wheel moves. Positive values describe a movement to the left, negative values describe a movement to the right.button_state
- The current state of mouse buttons.
§Returns
Returns Ok(()) success, or a VboxError
on failure.
§Example
use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::{MouseButtonState, SessionType};
let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();
let console = session.get_console().unwrap();
let mouse = console.get_mouse().unwrap();
mouse.put_mouse_event_absolute(1,1,1,1,MouseButtonState::Left).unwrap();
Sourcepub fn get_absolute_supported(&self) -> Result<bool, VboxError>
pub fn get_absolute_supported(&self) -> Result<bool, VboxError>
Whether the guest OS supports absolute mouse pointer positioning or not.
§Returns
Returns bool success, or a VboxError
on failure.
§Example
use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::SessionType;
let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();
let console = session.get_console().unwrap();
let mouse = console.get_mouse().unwrap();
let supported = mouse.get_absolute_supported().unwrap();
Sourcepub fn get_relative_supported(&self) -> Result<bool, VboxError>
pub fn get_relative_supported(&self) -> Result<bool, VboxError>
Whether the guest OS supports relative mouse pointer positioning or not.
§Returns
Returns bool success, or a VboxError
on failure.
§Example
use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::SessionType;
let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();
let console = session.get_console().unwrap();
let mouse = console.get_mouse().unwrap();
let supported = mouse.get_relative_supported().unwrap();
Sourcepub fn get_touch_screen_supported(&self) -> Result<bool, VboxError>
pub fn get_touch_screen_supported(&self) -> Result<bool, VboxError>
Whether the guest OS has enabled the multi-touch reporting device, touchscreen variant.
§Returns
Returns bool success, or a VboxError
on failure.
§Example
use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::SessionType;
let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();
let console = session.get_console().unwrap();
let mouse = console.get_mouse().unwrap();
let supported = mouse.get_touch_screen_supported().unwrap();
Sourcepub fn get_touch_pad_supported(&self) -> Result<bool, VboxError>
pub fn get_touch_pad_supported(&self) -> Result<bool, VboxError>
Whether the guest OS has enabled the multi-touch reporting device, touchpad variant.
§Returns
Returns bool success, or a VboxError
on failure.
§Example
use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::SessionType;
let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();
let console = session.get_console().unwrap();
let mouse = console.get_mouse().unwrap();
let supported = mouse.get_touch_pad_supported().unwrap();
Sourcepub fn get_needs_host_cursor(&self) -> Result<bool, VboxError>
pub fn get_needs_host_cursor(&self) -> Result<bool, VboxError>
Whether the guest OS can currently switch to drawing it’s own mouse cursor on demand.
§Returns
Returns bool success, or a VboxError
on failure.
§Example
use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::SessionType;
let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();
let console = session.get_console().unwrap();
let mouse = console.get_mouse().unwrap();
let supported = mouse.get_needs_host_cursor().unwrap();
Sourcepub fn get_event_source(&self) -> Result<EventSource, VboxError>
pub fn get_event_source(&self) -> Result<EventSource, VboxError>
Event source for mouse events.
§Returns
Returns a new instance of the EventSource
class on success, or a VboxError
on failure.
§Example
use virtualbox_rs::{Session, VirtualBox};
use virtualbox_rs::enums::SessionType;
let vbox = VirtualBox::init().unwrap();
let mut session = Session::init().unwrap();
let machine = vbox.
find_machines("Freebsd_14").unwrap();
machine.lock_machine(&mut session, SessionType::Shared).unwrap();
let console = session.get_console().unwrap();
let mouse = console.get_mouse().unwrap();
let event_source = mouse.get_event_source().unwrap();