Skip to content

Commit

Permalink
BF: with a retina display and Window.units='pix' mouse.getPos needs /2
Browse files Browse the repository at this point in the history
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 4, 2019
1 parent 03c1030 commit a78d744
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions psychopy/event.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a78d744

Please sign in to comment.