Last active
July 12, 2021 01:13
-
-
Save nickcheng/01dc00105bc21bbcd046bcd1957f60b2 to your computer and use it in GitHub Desktop.
Revisions
-
nickcheng revised this gist
Jul 12, 2021 . No changes.There are no files selected for viewing
-
nickcheng created this gist
Aug 14, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ -- HANDLE SCROLLING local deferred = false overrideRightMouseDown = hs.eventtap.new({ hs.eventtap.event.types.rightMouseDown }, function(e) --print("down")) deferred = true return true end) overrideRightMouseUp = hs.eventtap.new({ hs.eventtap.event.types.rightMouseUp }, function(e) -- print("up")) if (deferred) then overrideRightMouseDown:stop() overrideRightMouseUp:stop() hs.eventtap.rightClick(e:location()) overrideRightMouseDown:start() overrideRightMouseUp:start() return true end return false end) local oldmousepos = {} local scrollmulty = -4 -- negative multiplier makes mouse work like traditional scrollwheel local scrollmultx = -1 dragRightToScroll = hs.eventtap.new({ hs.eventtap.event.types.rightMouseDragged }, function(e) -- print("scroll"); deferred = false oldmousepos = hs.mouse.getAbsolutePosition() local dx = -e:getProperty(hs.eventtap.event.properties['mouseEventDeltaX']) local dy = -e:getProperty(hs.eventtap.event.properties['mouseEventDeltaY']) local scroll = hs.eventtap.event.newScrollEvent({dx * scrollmultx, dy * scrollmulty},{},'pixel') -- put the mouse back hs.mouse.setAbsolutePosition(oldmousepos) return true, {scroll} end) overrideRightMouseDown:start() overrideRightMouseUp:start() dragRightToScroll:start()