aboutsummaryrefslogtreecommitdiffstats
path: root/mouse.lua
diff options
context:
space:
mode:
authorTeddy Wing2019-06-14 20:32:51 +0200
committerTeddy Wing2019-06-15 20:31:39 +0200
commit9abc2e23458b352f01a463329d7cee194463d8e3 (patch)
tree3835f9e9853a26771f4336e346188327ff70139e /mouse.lua
parentb6e2be3b7aedcfaf352b45f612ebf775c480c60c (diff)
downloaddothammerspoon-9abc2e23458b352f01a463329d7cee194463d8e3.tar.bz2
mouse: Send mouse down and up events separately
Send 'down' when pressing the key, and 'up' when releasing. This sort of enables us to drag things, but I wasn't able to get an animation while dragging a window to test this. Looks like I'll need to work out a way to send mouse dragged events.
Diffstat (limited to 'mouse.lua')
-rw-r--r--mouse.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/mouse.lua b/mouse.lua
index 4b9bb79..2e49668 100644
--- a/mouse.lua
+++ b/mouse.lua
@@ -40,6 +40,16 @@ function mouse.click()
-- TODO: key down is mouse down, key up is mouse up
end
+function mouse.click_down()
+ local position = hs.mouse.getAbsolutePosition()
+ hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, position):post()
+end
+
+function mouse.click_up()
+ local position = hs.mouse.getAbsolutePosition()
+ hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, position):post()
+end
+
function mouse.right(amount)
return function()
local position = hs.mouse.getRelativePosition()
@@ -89,7 +99,7 @@ mouse_mode:bind({}, 'pad1', mouse.bottom_left(100), nil, mouse.bottom_left(100))
mouse_mode:bind({}, 'pad2', mouse.bottom(100), nil, mouse.bottom(100))
mouse_mode:bind({}, 'pad3', mouse.bottom_right(100), nil, mouse.bottom_right(100))
mouse_mode:bind({}, 'pad4', mouse.left(100), nil, mouse.left(100))
-mouse_mode:bind({}, 'pad5', mouse.click)
+mouse_mode:bind({}, 'pad5', mouse.click_down, mouse.click_up)
mouse_mode:bind({}, 'pad6', mouse.right(100), nil, mouse.right(100))
mouse_mode:bind({}, 'pad7', mouse.top_left(100), nil, mouse.top_left(100))
mouse_mode:bind({}, 'pad8', mouse.top(100), nil, mouse.top(100))