expyriment.io.Mouse

class expyriment.io.Mouse(show_cursor=True, track_button_events=None, track_motion_events=None)

A class implementing a mouse input.

Methods

__init__(show_cursor=True, track_button_events=None, track_motion_events=None)

Initialize a mouse input.

Parameters :

show_cursor : bool, optional

shows mouse cursor (default = True)

track_button_events : bool, optional

track button events via Pygame queue (default = True)

track_motion_events : bool, optional

track motion events via Pygame queue (default = False)

Notes

It is strongly suggest to avoid tracking of motions events, (track_motion_events=True), because it quickly causes an overflow in the Pygame event queue and you might consequently loose important events.

check_button_pressed(button_number)

Return (True/False) if a specific button is currently pressed.

Returns :

btn_id : int

button number (0,1,2)

check_wheel()

Check the mouse wheel.

Returns :

direction : str

“up” or “down” if mouse wheel has been recently rotated upwards or downwards otherwise it returns None.

clear()

Clear the event cue from mouse events.

get_cursor()

Get the cursor.

get_last_button_down_event()

Get the last button down event.

Returns :

btn_id : int

button number (0,1,2) or 3 for wheel up or 4 for wheel down

get_last_button_up_event()

Get the last button up event.

Returns :

btn_id : int

button number (0,1,2)

hide_cursor(track_button_events=False, track_motion_events=False)

Hide the cursor.

Parameters :

track_button_events : bool, optional

tracking button events (default = True)

track_motion_events : bool, optional

tracking motion events (default = False)

logging

Getter for logging.

position

Getter of mouse position.

pressed_buttons

Getter for pressed buttons.

set_cursor(size, hotspot, xormasks, andmasks)

Set the cursor.

Parameters :

size : (int, int)

size of the cursor

hotspot : (int, int)

position of the hotspot (0,0 is top left)

xormask : list

sequence of bytes with cursor xor data masks

andmask : list

sequence of bytes with cursor bitmask data

set_logging(onoff)

Set logging of this object on or off

Parameters :

onoff : bool

set logging on (True) or off (False)

Notes

See also design.experiment.set_log_level fur further information about event logging.

show_cursor(track_button_events=True, track_motion_events=False)

Show the cursor.

Parameters :

track_button_events : bool, optional

tracking button events (default = True)

track_motion_events : bool, optional

tracking motion events (default = False)

track_button_events

Getter for track_button_events.

track_motion_events

Getter for track_motion_events.

Switch on/off the buffering of motion events in the Pygame event queue.

Notes

It is strongly suggest to avoid tracking of motions events, (track_motion_events=True), because it quickly causes an overflow in the Pygame event queue and you might consequently loose important events.

wait_event(wait_button=True, wait_motion=True, buttons=None, duration=None, wait_for_buttonup=False)

Wait for a mouse event (i.e., motion, button press or wheel event)

Parameters :

wait_button : bool, optional

set ‘False’ to ignore for a button presses (default=True)

wait_motion : bool, optional

set ‘False’ to ignore for a mouse motions (default=True)

buttons : int or list, optional

a specific button or list of buttons to wait for

duration : int, optional

the maximal time to wait in ms

wait_for_buttonup : bool, optional

if True it waits for button-up default=False)

Returns :

event_id : int

id of the event that quited waiting

move : bool

True if a motion occured

pos : (int, int)

mouse position (tuple)

rt : int

reaction time

Notes

button id coding

  • None for no mouse button event or
  • 0,1,2 for left. middle and right button or
  • 3 for wheel up or
  • 4 for wheel down (wheel works only for keydown events).
wait_motion(duration=None)

Wait for a mouse motion.

Parameters :

duration : int, optional

maximal time to wait in ms

Returns :

pos : (int, int)

mouse position (tuple)

rt : int

reaction time

wait_press(buttons=None, duration=None, wait_for_buttonup=False)

Wait for a mouse button press or mouse wheel event.

Parameters :

buttons : int or list, optional

a specific button or list of buttons to wait for

duration : int, optional

maximal time to wait in ms

wait_for_buttonup : bool, optional

if True it waits for button-up

Returns :

event_id : int

id of the event that quited waiting

pos : (int, int)

mouse position (tuple)

rt : int

reaction time

Notes

button id coding

  • None for no mouse button event or
  • 0,1,2 for left. middle and right button or
  • 3 for wheel up or
  • 4 for wheel down (wheel works only for keydown events).

Previous topic

expyriment.io.MarkerOutput

Next topic

expyriment.io.OutputFile

This Page