Skip to content
Permalink
Browse files

BF: with a retina display and Window.units='pix' mouse.getPos needs /2

The (actual) coords returned by the retina display are twice the
(virtual) coords returned by the window. So mouse.getPos needs to convert
these back to virtual coords as well (by dividing by 2)
  • Loading branch information...
peircej committed Jul 3, 2019
1 parent 03c1030 commit a78d74420b22f7dba0cf1549275d9fbc082344ef
Showing with 3 additions and 0 deletions.
  1. +3 −0 psychopy/event.py
@@ -643,6 +643,7 @@ def getPos(self):
else:
lastPosPix = lastPosPix - numpy.array(self.win.size) / 2
self.lastPos = self._pix2windowUnits(lastPosPix)

return copy.copy(self.lastPos)

def mouseMoved(self, distance=None, reset=False):
@@ -849,6 +850,8 @@ def isPressedIn(self, shape, buttons=(0, 1, 2)):

def _pix2windowUnits(self, pos):
if self.win.units == 'pix':
if self.win.useRetina:
pos /= 2.0
return pos
elif self.win.units == 'norm':
return pos * 2.0 / self.win.size

0 comments on commit a78d744

Please sign in to comment.
You can’t perform that action at this time.