Skip to content

Commit

Permalink
Merge pull request #43 from wolfmanstout/fix_scrolling
Browse files Browse the repository at this point in the history
Apply mouse wheel multipliers directly to the event to avoid failure …
  • Loading branch information
drmfinlay committed Nov 12, 2018
2 parents a8a4cbc + 0752515 commit 2c11cec
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions dragonfly/actions/action_mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,52 +353,53 @@ def _process_relative_position(self, spec, events):
(win32con.MOUSEEVENTF_RIGHTUP, 0)),
"middle": ((win32con.MOUSEEVENTF_MIDDLEDOWN, 0),
(win32con.MOUSEEVENTF_MIDDLEUP, 0)),
"wheelup": ((win32con.MOUSEEVENTF_WHEEL, 120),
(win32con.MOUSEEVENTF_WHEEL, 0)),
"stepup": ((win32con.MOUSEEVENTF_WHEEL, 40),
(win32con.MOUSEEVENTF_WHEEL, 0)),
"wheeldown": ((win32con.MOUSEEVENTF_WHEEL, -120),
(win32con.MOUSEEVENTF_WHEEL, 0)),
"stepdown": ((win32con.MOUSEEVENTF_WHEEL, -40),
(win32con.MOUSEEVENTF_WHEEL, 0)),
"wheelright": ((MOUSEEVENTF_HWHEEL, 120),
(MOUSEEVENTF_HWHEEL, 0)),
"stepright": ((MOUSEEVENTF_HWHEEL, 40),
(MOUSEEVENTF_HWHEEL, 0)),
"wheelleft": ((MOUSEEVENTF_HWHEEL, -120),
(MOUSEEVENTF_HWHEEL, 0)),
"stepleft": ((MOUSEEVENTF_HWHEEL, -40),
(MOUSEEVENTF_HWHEEL, 0)),
"four": ((win32con.MOUSEEVENTF_XDOWN, 1),
(win32con.MOUSEEVENTF_XUP, 1)),
"five": ((win32con.MOUSEEVENTF_XDOWN, 2),
(win32con.MOUSEEVENTF_XUP, 2)),
}

_wheel_flags = {
"wheelup": (win32con.MOUSEEVENTF_WHEEL, 120),
"stepup": (win32con.MOUSEEVENTF_WHEEL, 40),
"wheeldown": (win32con.MOUSEEVENTF_WHEEL, -120),
"stepdown": (win32con.MOUSEEVENTF_WHEEL, -40),
"wheelright": (MOUSEEVENTF_HWHEEL, 120),
"stepright": (MOUSEEVENTF_HWHEEL, 40),
"wheelleft": (MOUSEEVENTF_HWHEEL, -120),
"stepleft": (MOUSEEVENTF_HWHEEL, -40),
}

def _process_button(self, spec, events):
parts = spec.split(":", 1)
button = parts[0].strip()
if len(parts) == 1: special = 1
else: special = parts[1].strip()

if button not in self._button_flags:
return False
flag_down, flag_up = self._button_flags[button]
if button in self._button_flags:
flag_down, flag_up = self._button_flags[button]

# Disallow ':up' and ':down' for scroll events.
if special in ("up", "down") and ("wheel" in button or "step" in button):
return False
elif special == "down":
event = _Button(flag_down)
elif special == "up":
event = _Button(flag_up)
else:
if special == "down":
event = _Button(flag_down)
elif special == "up":
event = _Button(flag_up)
else:
try:
repeat = int(special)
except ValueError:
return False
flag_series = (flag_down, flag_up) * repeat
event = _Button(*flag_series)
elif button in self._wheel_flags:
flag = self._wheel_flags[button]
try:
repeat = int(special)
except ValueError:
return False
flag_series = (flag_down, flag_up) * repeat
event = _Button(*flag_series)
flag = (flag[0], repeat * flag[1])
event = _Button(flag)
else:
return False

events.append(event)
return True
Expand Down

0 comments on commit 2c11cec

Please sign in to comment.