Skip to content

Commit a78d744

Browse files
committed
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)
1 parent 03c1030 commit a78d744

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

psychopy/event.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ def getPos(self):
643643
else:
644644
lastPosPix = lastPosPix - numpy.array(self.win.size) / 2
645645
self.lastPos = self._pix2windowUnits(lastPosPix)
646+
646647
return copy.copy(self.lastPos)
647648

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

850851
def _pix2windowUnits(self, pos):
851852
if self.win.units == 'pix':
853+
if self.win.useRetina:
854+
pos /= 2.0
852855
return pos
853856
elif self.win.units == 'norm':
854857
return pos * 2.0 / self.win.size

0 commit comments

Comments
 (0)