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

Allow hs.eventtap.event.newMouseEvent() to accept mouseMoved #2144

Merged
merged 1 commit into from Sep 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 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