Class EventQueue
pygame's event queue (pygame.event) in pygame's spelling: the queue of Default,
the process-wide context, filled by Display's window and by Post(Event), drained by
Get(). Every member forwards to PygameContext.Default.Events (PygameEventQueue,
which documents the behaviour in full).
public static class EventQueue
- Inheritance
-
EventQueue
- Inherited Members
Remarks
Process-wide on purpose, as SDL's is: a callback deep inside play can post to it without a handle. The
footgun is the same as pygame's: two loops draining it in one process steal each other's events, and tests that
use it must not run in parallel with each other. A game that runs beside another takes a
PygameContext of its own (DR-41) and is posted to through its Events.
Thread-safe: any thread may post, and the window's input moves into the queue only when Get() or Pump() runs, on the caller's thread. Quit() empties it. Posting works before any display is set, and the queue has no capacity limit and no blocked types.
Reference: src_c/event.c (pygame-ce 2.5.8).
Properties
Count
The number of pending events of the default context, without pumping; for tests and diagnostics.
public static int Count { get; }
Property Value
Methods
Clear()
pygame.event.clear() on the default context: drops every pending event, the window's buffered input included.
public static void Clear()
Get()
pygame.event.get() on the default context: pumps the window's input, then takes every pending event, oldest first.
public static IReadOnlyList<Event> Get()
Returns
- IReadOnlyList<Event>
The events, empty when there are none; the caller owns the list.
Post(Event)
pygame.event.post(event) on the default context: appends an event after the ones already pending.
public static void Post(Event @event)
Parameters
eventEventThe event; queued as is (not copied), so changing it before it is taken changes what is read.
Exceptions
- ArgumentNullException
Thrown when
eventis null.
Pump()
pygame.event.pump() on the default context: moves the window's buffered input into the queue, resizing the
display surface for a resize, without taking anything out. A no-op without an interactive window.
public static void Pump()