Skip to content

Commit

Permalink
Allow hs.eventtap.event.newMouseEvent() to accept mouseMoved
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsj committed Sep 22, 2019
1 parent 79ac945 commit 1266441
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions extensions/eventtap/event.m
Expand Up @@ -860,6 +860,8 @@ static int eventtap_event_newMouseEvent(lua_State* L) {
button = kCGMouseButtonRight;
else if (strcmp(buttonString, "other") == 0)
button = kCGMouseButtonCenter;
else if (strcmp(buttonString, "none") == 0)
button = 0;

if (!lua_isnoneornil(L, 4) && (lua_type(L, 4) == LUA_TTABLE)) {
lua_pushnil(L);
Expand Down
4 changes: 3 additions & 1 deletion extensions/eventtap/init.lua
Expand Up @@ -140,7 +140,7 @@ end
--- Creates a new mouse event
---
--- Parameters:
--- * eventtype - One of the values from `hs.eventtap.event.types`
--- * eventtype - One of the mouse related values from `hs.eventtap.event.types`
--- * point - An hs.geometry point table (i.e. of the form `{x=123, y=456}`) indicating the location where the mouse event should occur
--- * modifiers - An optional table (e.g. {"cmd", "alt"}) containing zero or more of the following keys:
--- * cmd
Expand All @@ -160,6 +160,8 @@ function module.event.newMouseEvent(eventtype, point, modifiers)
button = "right"
elseif eventtype == types["otherMouseDown"] or eventtype == types["otherMouseUp"] or eventtype == types["otherMouseDragged"] then
button = "other"
elseif eventtype == types["mouseMoved"] then
button = "none"
else
print("Error: unrecognised mouse button eventtype: " .. tostring(eventtype))
return nil
Expand Down

0 comments on commit 1266441

Please sign in to comment.