# HG changeset patch # User Simon Cross # Date 1315740134 -7200 # Node ID f5846a46e9c59e9a38da1bd92b7306a1b32f7d24 # Parent 0196455fa4325eb6b978843e66a4f40c4205567c Add base class for user events. diff -r 0196455fa432 -r f5846a46e9c5 mamba/engine.py --- a/mamba/engine.py Sun Sep 11 13:11:52 2011 +0200 +++ b/mamba/engine.py Sun Sep 11 13:22:14 2011 +0200 @@ -2,7 +2,7 @@ import pygame.event import pygame.display -from pygame.locals import QUIT +from pygame.locals import QUIT, USEREVENT class Engine(object): @@ -19,3 +19,17 @@ if ev.type is QUIT: return flip() + + +class UserEvent(object): + + utype = "UNKNOWN" + + @classmethod + def post(cls, **kws): + ev = pygame.event.Event(USEREVENT, utype=cls.utype, **kws) + pygame.event.post(ev) + + @classmethod + def matches(cls, ev): + return ev.type is USEREVENT and ev.utype == cls.utype