[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] event.get(), event.poll() only return keyup/keydown while mouse is moving



I found the problem - I was calling pygame.event.poll() in another module. Oops. Thanks for the response anyway.

I'm using double underscores so that the method is private. It's a member of a class, and the method is only to be called from the class itself. In my design there are several event sources, and only one of them is pygame. In the poll method I query each one of these sources and throw them all into the same queue. Thus engine.poll() calls engine.__poll_pygame, engine.__poll_net, and a few other event sources.

Here's more info on private class members:
http://www.diveintopython.org/fileinfo_private.html

luke p wrote:

are you calling __poll_pygame in a loop?  pygame.event.get() only gets
the currently queued keypresses, it doesn't just sit there getting
events.  You have to call it.  so maybe you are only calling
__poll_pygame when the mouse is moving or something of that sort.  By
the way, why are you using __'s for naming your functions? just
curious.

On 5/17/05, Patrick Chasco <patrick@xxxxxxxxxxxxxx> wrote:


I'm having a problem with event.get() and event.poll(). It seems that
these two functions will only return KEYUP/KEYDOWN events while the
mouse is moving over the pygame window, or moving at all while in
fullscreen mode. event.wait() works as intended.

Here's the code:
[from engine.py]
def __init_engine(self, mode, fullscreen):
  pygame.init()
  if fullscreen:
      fullscreen = pygame.FULLSCREEN
  self.screen = pygame.display.set_mode(mode, fullscreen)

[from event.py]
def __poll_pygame(self):
  for e in pygame.event.get():
      print e.type

Anybody have any ideas?