-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Labels
Description
Describe the problem
I want to reposition the mouse pointer within the tauri window.
I have read that winit has functions to do that, so I would assume tao can also do that.
Since tao is not exposed by tauri, I cannot use those capabilities.
Describe the solution you'd like
I would like an API function where I can pass coordinates relative to the top left corner of the tauri window which would reposition the mouse pointer.
For example, if I would do set_pointer_position(0,0), the cursor would jump to the top left corner.
Alternatives considered
I have created a custom tauri command using winapi, which looks like this:
#[tauri::command]
fn set_pointer_position(window: tauri::Window, x: i32, y: i32) {
let inner_size = window.inner_size().unwrap();
let outer_size = window.outer_size().unwrap();
let pos = window.inner_position().unwrap();
unsafe {
if winapi::um::winuser::SetPhysicalCursorPos(pos.x + x, pos.y + y + (outer_size.height as i32 - inner_size.height as i32)) == 0 {
panic!("SetCursorPos failed");
}
}
}Additional context
No response
Reactions are currently unavailable