dragonfly icon indicating copy to clipboard operation
dragonfly copied to clipboard

Double click not working (Kaldi, OSX)

Open denvaar opened this issue 1 year ago • 4 comments

Single click Mouse actions work great, however I cannot get a double click to work. For example, I'd like to hover the cursor over a word and use the double click action to select it. This seems like a bug to me, but maybe I'm doing something wrong.

Mouse("left:2")

I've tried many variations, like adding a pause, or chaining two single click mouse actions together, but nothing seems to do the trick. There is no error in the console either.

I use Kaldi engine and I'm on macOS Monterey Version 12.4 (Macbook pro)

Thanks for the help.

denvaar avatar Aug 05 '22 16:08 denvaar

Hello Denver,

Thank you for reporting this problem. It is indeed a bug with the library. It looks like scrolling is broken on macOS too. I'll have both fixed in the next version. That may be some time off, however.

In the meantime, the following code will allow you to double click:

from dragonfly import MappingRule, CompoundRule, Function

# pynput is the input library Dragonfly uses on macOS and should
#  be installed already.
from pynput.mouse import Controller, Button

controller = Controller()

def left_click(n):
    controller.click(Button.left, n)


# Invoke the `left_click' function when "double click" is spoken.
# With a `MappingRule',
class DoubleClickRule1(MappingRule):
    mapping = {
        "double click": Function(lambda: left_click(2)),
    }

# or `CompoundRule'.
class DoubleClickRule2(CompoundRule):
    spec = "double click"
    def _process_recognition(self, node, extras):
        left_click(2)

Triple click is broken too. Invoke the left_click function with 3 instead to triple click.

Hope this helps!

drmfinlay avatar Aug 10 '22 09:08 drmfinlay

Thanks @Danesprite 👍

denvaar avatar Aug 11 '22 03:08 denvaar

No problem. I should have these bugs fixed soon.

drmfinlay avatar Aug 11 '22 04:08 drmfinlay

This is fixed on the master branch. There is one limitation though. Double-click and triple-click will only work when the repeat syntax is used:

{
   "double click": Mouse("left:2"),
   "triple click": Mouse("left:3")
}

The following will not work properly on macOS:

Mouse("left, left").execute()
Mouse("left, left, left").execute()

I'll make another comment, and close this issue, after the next release version is out.

drmfinlay avatar Sep 12 '22 08:09 drmfinlay