I tried this and it seems to work. - OS Mavericks (10.9.5) - MacBook Pro Retina - pygame 1.9.1 via macports - ran from terminal using: python2.7 x.py (where x.py is the file name I copied your code sample into)
For me the focus changed to the pygame window and when I pressed escape the program terminated (as expected). The only difference I can see between your setup and mine is that I installed PG through macports and you used fink. Could that make a difference? Maybe you could try installing pygame through the .dmg package and see if that makes a difference? Otherwise I’m not sure what to suggest… HTH, Joe On Dec 10, 2014, at 13:35, James Mazer <james.ma...@yale.edu> wrote: > Is there a trick for getting pygame to take the keyboard focus under > osx? I'm trying to port an app from linux and ran into something odd. > This simple program: > > import pygame > pygame.init() > screen = pygame.display.set_mode((100,100)) > while 1: > pygame.event.pump() > if pygame.key.get_pressed()[pygame.K_ESCAPE]: > break > > doesn't work under osx (python 2.7 & pygame 1.9.1 via fink). The > pygame window appears and changes color when clicked indicating it has > the focus (and pygame.key.get_focused returns 1), but clicks in the > pygame window are directed to the terminal where the program was run > from (get_pressed() is always all zeros). > > Am I missing something obvious here? This works fine under linux. An > hours or so of googling seems to indicate others have had this > problem, but there's no obvious answer and nothing recent. > > thanks, > /jamie > > -- > James Mazer > Department of Neurobiology > Yale School of Medicine > phone: 203-737-5853 > fax: 203-785-5263 > url: http://jackknife.med.yale.edu