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

Double click #373

Closed
ricardopolo opened this issue Feb 18, 2022 · 15 comments · Fixed by nut-tree/libnut-core#115 or #389
Closed

Double click #373

ricardopolo opened this issue Feb 18, 2022 · 15 comments · Fixed by nut-tree/libnut-core#115 or #389
Assignees
Labels
enhancement Enhancement to existing features libnut Root cause located in libnut
Milestone

Comments

@ricardopolo
Copy link

ricardopolo commented Feb 18, 2022

I'm trying to simulate a double click in mac. In RobotJs I use the double click option http://robotjs.io/docs/syntax#mouseclickbutton-double

what can I use for doing a double click in Nutjs?

I tested sending two click events on after each other and I does not work

Thanks

@ricardopolo
Copy link
Author

@s1hofmann any advice?

@s1hofmann
Copy link
Member

Unfortunately nut.js does currently not expose a dedicated double-click method which would be required for macOS.
One way to work around this could be the Cmd+O shortcut, in case you’re trying to open an item

@ricardopolo
Copy link
Author

ricardopolo commented Feb 22, 2022

Do you think It will be implement soon?

I was thinking of nut as a replacement for robot.is but the lack of double click or drag won’t allow us

thanks a lot

@s1hofmann
Copy link
Member

Hi @ricardopolo 👋

To be honest, this has a rather low priority at the moment.
You're actually the first one to report this issue (same for #374) and I've yet to decide how this should be best reflected API wise.

@ricardopolo
Copy link
Author

Thanks @s1hofmann.

I hope in the mid term this library could be a full replacement of RobotJs. You are doing a great library!!

@s1hofmann
Copy link
Member

I'll give you a ping in here once it's available

@s1hofmann s1hofmann self-assigned this Apr 17, 2022
@s1hofmann s1hofmann added enhancement Enhancement to existing features libnut Root cause located in libnut labels Apr 17, 2022
@s1hofmann s1hofmann added this to the 🐭 milestone Apr 17, 2022
@s1hofmann s1hofmann reopened this Apr 17, 2022
s1hofmann added a commit that referenced this issue Apr 17, 2022
* (#373) Extend mouse provider interface with generich click and doubleClick methods

* (#373) Updated implementation to match updated interface

* (#373) Provide public API for click and doubleClick
s1hofmann added a commit that referenced this issue Apr 17, 2022
@s1hofmann
Copy link
Member

/cc @ricardopolo

You can give mouse.click(Button.LEFT/Button.MIDDLE/Button.RIGHT) and mouse.doubleClick(Button.LEFT/Button.MIDDLE/Button.RIGHT) a try with the latest snapshot release.

npm i @nut-tree/nut-js@next

@adamjerickson
Copy link

I'm trying to use this doubleClick feature and it seems to only perform a single click. I'm running inside electron, on MacOS, in the 'main' area. "@nut-tree/nut-js": "^3.1.1",

await mouse.doubleClick(Button.LEFT);

Any thoughts on what might be wrong?

@s1hofmann
Copy link
Member

Hi @adamjerickson 👋

I just did a double check and confirmed that double clicking is working as expected on my macOS machine.
Tested on both node 18 and Electron 24.1.3

@adamjerickson
Copy link

adamjerickson commented May 4, 2023

The app I'm building this into is on node 16.14.2 with same version of electron. Do you have an easy way to test with that version of node? Otherwise I'll try to bootstrap something.

@s1hofmann
Copy link
Member

I did another test with Electron 16.2.8 which worked flawlessly.

See https://share.cleanshot.com/YFZJLJpZ

@adamjerickson
Copy link

Okay, thanks. Must be something in my code. I'll dig deeper. Thanks.

@adamjerickson
Copy link

adamjerickson commented May 4, 2023

Is there a reason you have the doubleClick call inside the Click promise resolution? Does it need to be after a single click?
Screen Shot 2023-05-04 at 4 27 00 PM

@s1hofmann
Copy link
Member

The simple reason for this is to shift the focus away from the Electron window.

Without it the double click on the icon wouldn’t work, because one of the clicks would first shift the focus.
Maybe something to consider for you as well?

@parikshit-dp
Copy link

@s1hofmann maybe you can this in the documentation. I too had similar problem and first doing a click and then doubleClick worked. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to existing features libnut Root cause located in libnut
Projects
None yet
4 participants