I'm using a Logitech mouse with MacOS, and from observation:
- the left button executes its action on release (button up) in many (but not all) cases
- the right button executes its action on press (button down) in all (?) cases
I'd like to make the right button (conditionally) execute the action on up instead of down. I'm not sure if this is possible. Further context:
I have a simple script (below) that allows me to hold the right button down and use the scroll wheel to adjust system volume. It works, but the default button action (e.g. a context menu in a browser) still gets executed when the button goes down. I'd like to not execute the action if the scroll wheel is fiddled with (thus I need to wait until the button is lifted to execute, or skip, the action). Is this possible? I'm guessing I'd need a very different approach than what I have below (this is just for reference in terms of what I'm currently doing).
local eventtap = require("hs.eventtap")
volume_control = eventtap.new({eventtap.event.types.scrollWheel}, function(event)
if eventtap.checkMouseButtons()[2] then
hs.eventtap.keyStroke({}, "escape", 0); -- Make the context menu disappear
local vol = hs.audiodevice.defaultOutputDevice():volume()
if (event:getProperty(hs.eventtap.event.properties.scrollWheelEventDeltaAxis1) < 0) then vol = vol + 2 end
if (event:getProperty(hs.eventtap.event.properties.scrollWheelEventDeltaAxis1) > 0) then vol = vol - 2 end
hs.audiodevice.defaultOutputDevice():setVolume(vol)
hs.alert.closeAll()
hs.alert.show(string.format("Volume: %3.0f%%", hs.audiodevice.defaultOutputDevice():volume()), {}, hs.screen.mainScreen(), 0.4)
return true
end
end):start()