Skip to content

Commit

Permalink
Add move_by method (fixes AltF02#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
circles-png committed Aug 19, 2023
1 parent 7b352fc commit a8f11fe
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ impl Mouse {
sys::Mouse::release(button)?;
Ok(())
}

/// Move the mouse, relative to the current position.
///
/// # Errors
///
/// Fails if [`Self::get_position`] or [`Self::move_to`] fails.
pub fn move_by(&self, delta_x: i32, delta_y: i32) -> Result<(), Box<dyn std::error::Error>> {
let position = self.get_position()?;
self.move_to(position.x + delta_x, position.y + delta_y)?;
Ok(())
}
}

impl Default for Mouse {
Expand Down

0 comments on commit a8f11fe

Please sign in to comment.