On Sat, Sep 1, 2012 at 6:15 PM, darkfeline <[email protected]> wrote:

> Hi everyone!
>
> This is my first time here so I apologize in advance if I break some rules.
>
> I've been using pyglet for a while and I've found the EventDispatcher's
> push_handlers() and pop_handlers() implementation very inflexible.  Very
> often I want to add handlers between others in the stack, and likewise
> remove some in the middle of the stack.  One particular use-case is for
> example having sprites or other game objects which need to receive events
> but are created and deleted during the lifetime of the game, but there are
> many others (scene management is another) which can benefit greatly from
> this.
>
> The change is as simple as going from:
>     def push_handlers(self, *args, **kwargs):
> to
>     def push_handlers(self, index, *args, **kwargs):
> and similarly for pop_handlers().  I realize as an API change this may be
> unfavorable, in which case new method names can be made (e.g.
> push_handlers_at()).  This is a very small change (Only 4 lines need to be
> changed, or slightly more added with the new method name implementation)
> but a huge increase in flexibility in pyglet's event system.
>
> What are everyone's thoughts on this matter?


It sounds like you either have very complex needs, in which case you should
probably just write your own functions to manipulate the stacks yourself,
or your normal needs are suffering from an abnormally complex
implementation.  :-)  Just my opinion -- and I'm just another pyglet user.
 Every time I've found myself wishing for similar modifications to pyglet's
event design, I soon found that conforming to the existing design forced me
to improve my own code's structure quite a bit.

By the way, you can already remove handler(s) from the middle of the stack,
providing you know exactly what callable was pushed onto it:

http://pyglet.org/doc/api/pyglet.event.EventDispatcher-class.html#remove_handler

~ Nathan

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en.

Reply via email to