[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] Event polling, is there a standard trick to combine ...
Peter Goode writes:
> (not abs position I think,
> which won't work outside the application window, unlike
> then drag which will...)
When I first read this, I thought "What's he talking about? SDL
shouldn't be generating any events if the mouse is outside the
application window." Then I tested it...
Something weird is going on. With event.set_grab(0), relative and
absolute MOUSEMOTION events are still generated when the mouse is
outside the application window, _if and only if_ a mouse button was
down when the mouse was moved off the pygame window. As soon as the
mouse button is released, no new events are registered.
Furthermore, the mouse x and y positions are clamped to the top,
bottom, left and right edge _values_, but not to those edges
themselves. For example, if the mouse pointer is way off the window
to the left, get_pos() might return (0, 124) - the x value is clamped,
but the y value is still free (again, only while the mouse button is
down). As a result, get_rel() half-works while the mouse is above,
below, to the left or to the right of the window, but is completely
useless if the mouse is, say, to the upper-left of the window. Weird.
This might have some usefulness in a gesture-based input system, but
it's more likely that this is just unintended behavoir. I don't know
whether SDL or pygame is generating this weirdness, so I'll just shut
my word hole for now. Here's a script to demonstrate:
import pygame
screen = pygame.display.set_mode((400,300))
while 1:
e = pygame.event.poll()
if e.type == pygame.MOUSEMOTION:
print pygame.mouse.get_rel(), pygame.mouse.get_pos()
elif e.type == pygame.QUIT:
raise SystemExit
--
Futility
--
My high school guidance councellor once told me that I have a very short
attention span. The following day we were given the results of our career
placement tests. Mine said that I was going to die. My career placement
test was inaccurate. Turns out it's the other way around. -MG
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org