I am using Python Module "Mouse" to capture mouse inputs (more specifically, mouse coordinates, input button, and type of input). Source: https://github.com/boppreh/mouse
Looking at the source code for on_button() and on_click(), I am not sure how to pass the event_type back for "mouse button down" and "mouse button up" back to my code:
def left_mouse():
print('LEFT ', mouse.get_position())
# I want to get the [mouse button, example: left] and [type, example: up] from the logging
mouse.on_click(left_mouse)
Source code from MOUSE MODULE: on_button and on_click; I'm guessing I'm not calling callback appropriately but can't figure out what's the right approach:
def on_button(callback, args=(), buttons=(LEFT, MIDDLE, RIGHT, X, X2), types=(UP, DOWN, DOUBLE)):
""" Invokes `callback` with `args` when the specified event happens. """
if not isinstance(buttons, (tuple, list)):
buttons = (buttons,)
if not isinstance(types, (tuple, list)):
types = (types,)
def handler(event):
if isinstance(event, ButtonEvent):
if event.event_type in types and event.button in buttons:
callback(*args)
_listener.add_handler(handler)
return handler
def on_click(callback, args=()):
""" Invokes `callback` with `args` when the left button is clicked. """
return on_button(callback, args, [LEFT], [UP])
Thanks as always.
on_right_clickfunction. The function you're using is a synonym foron_left_click, they just shortened it toon_click:) docs