Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse drag doesn't work #102

Open
blesswinsamuel opened this issue Feb 26, 2023 · 4 comments
Open

Mouse drag doesn't work #102

blesswinsamuel opened this issue Feb 26, 2023 · 4 comments

Comments

@blesswinsamuel
Copy link

First of all, thank you for this library.

When I tried the example https://github.com/Narsil/rdev/blob/main/examples/grab.rs, it prints mouse move and click events. But, when I click and move the mouse while the mouse button is being clicked, it doesn't print those events. I expect MouseMove events to be printed between the ButtonPress(Left) and ButtonRelease(Left) events.

Here's the output:

My callback Event { time: SystemTime { tv_sec: 1677442442, tv_nsec: 943688000 }, name: None, event_type: ButtonPress(Left) }
My callback Event { time: SystemTime { tv_sec: 1677442448, tv_nsec: 466498000 }, name: None, event_type: ButtonRelease(Left) }
My callback Event { time: SystemTime { tv_sec: 1677442448, tv_nsec: 466626000 }, name: None, event_type: MouseMove { x: 474.41796875, y: 1146.15625 } }

Here's what I expect:

My callback Event { time: SystemTime { tv_sec: 1677442442, tv_nsec: 943688000 }, name: None, event_type: ButtonPress(Left) }
My callback Event { time: SystemTime { tv_sec: 1677442448, tv_nsec: 466626000 }, name: None, event_type: MouseMove { x: 123, y: 123 } }
My callback Event { time: SystemTime { tv_sec: 1677442448, tv_nsec: 466626000 }, name: None, event_type: MouseMove { x: 124, y: 124 } }
...
My callback Event { time: SystemTime { tv_sec: 1677442448, tv_nsec: 466498000 }, name: None, event_type: ButtonRelease(Left) }
My callback Event { time: SystemTime { tv_sec: 1677442448, tv_nsec: 466626000 }, name: None, event_type: MouseMove { x: 474.41796875, y: 1146.15625 } }

I'm using macOS Ventura 13.1 and rdev version 0.5.2.

@swithun-liu-backup
Copy link

I also encountered this problem in macOS Ventura 13.4 and rdev 0.5.3. Did you solve it?

@Narsil
Copy link
Owner

Narsil commented Jul 3, 2023

grabbing is unstable (it's really hard to make an OS independant API for it as not everything is even grabbable)
. Does the listen work ?

@swithun-liu-backup
Copy link

listen also doesn't work.

Here is my try:

fn main() {
    if let Err(error) = listen(callback) {
        println!("Error: {:?}", error)
    }

    fn callback(event: Event) {
        println!("My callback {:?}", event);
        match event.event_type {
            EventType::ButtonPress(button) => match button {
                Button::Right => {
                    println!("right btn press");
                },
                _ => (),
            },
            EventType::ButtonRelease(button) => match button {
                Button::Right => {
                    println!("right btn release");
                },
                _ => (),
            },
            EventType::MouseMove { x, y } => {
                println!("x: {}, y: {}", x, y);
            },
            _ => (),
        }
    }
}

This is output when I press right button, then move the mouse, and finally release right button.

My callback Event { time: SystemTime { tv_sec: 1688384409, tv_nsec: 912707000 }, name: None, event_type: ButtonPress(Right) }
right btn press
My callback Event { time: SystemTime { tv_sec: 1688384414, tv_nsec: 232347000 }, name: None, event_type: ButtonRelease(Right) }
right btn release

@Advait1306
Copy link

Did you find a solution to this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants