Package psychopy :: Module event :: Class Mouse
[frames] | no frames]

Class Mouse

source code

Easy way to track what your mouse is doing. It needn't be a class, but since Joystick works better as a class this may as well be one too for consistency

Create your visual.Window before creating a Mouse.

Instance Methods
 
__init__(self, visible=True, newPos=None, win=None) source code
 
setPos(self, newPos=(0, 0))
Sets the current postiion of the mouse (pygame only), in the same units as the :class:`~visual.Window` (0,0) is at centre
source code
 
getPos(self)
Returns the current postion of the mouse, ...
source code
 
getRel(self)
Returns the new position of the mouse relative to the last call to getRel or getPos, in the same units as the :class:`~visual.Window`.
source code
 
getWheelRel(self)
Returns the travel of the mouse scroll wheel since last call.
source code
 
getVisible(self)
Gets the visibility of the mouse (1 or 0)
source code
 
setVisible(self, visible)
Sets the visibility of the mouse to 1 or 0
source code
 
getPressed(self)
Returns a 3-item list indicating whether or not buttons 1,2,3 are currently pressed
source code
Method Details

__init__(self, visible=True, newPos=None, win=None)
(Constructor)

source code 
Parameters:
  • visible (True or False) - makes the mouse invisbile if necessary
  • newPos (None or [x,y]) - gives the mouse a particular starting position (pygame Window only)
  • win (None or Window) - the window to which this mouse is attached (the first found if None provided)

setPos(self, newPos=(0, 0))

source code 
Sets the current postiion of the mouse (pygame only), 
in the same units as the :class:`~visual.Window` (0,0) is at centre

:Parameters:
    newPos : (x,y) or [x,y]
        the new position on the screen

getPos(self)

source code 
Returns the current postion of the mouse, 
in the same units as the :class:`~visual.Window` (0,0) is at centre

getWheelRel(self)

source code 
Returns the travel of the mouse scroll wheel since last call. Returns a numpy.array(x,y) but for most wheels y is the only value that will change (except mac mighty mice?)

setVisible(self, visible)

source code 

Sets the visibility of the mouse to 1 or 0

NB when the mouse is not visible its absolute position is held at (0,0) to prevent it from going off the screen and getting lost! You can still use getRel() in that case.