It seems like you can not stack handlers using the @decorator, instead
you have to use push_handlers. Is this correct? In the below example,
it can have up to 3 event handlers, HANDLER A fires if it is the only
handler, or if it and "HANDLER C" are registered.

However if I have 'HANDLER A' and 'HANDLER B' registered, then only
'HANDLER B' fires.

Interestingly, if I have all three handlers registered, then A does
not fire, but B and C do.

I'm running Windows, pyglet 1.2.

#######################################
import pyglet

window = pyglet.window.Window()

label = pyglet.text.Label('Hello, world',
                          font_name='Times New Roman',
                          font_size=36,
                          x=window.width//2, y=window.height//2,
                          anchor_x='center',
anchor_y='center')
@window.event
def on_draw():
    window.clear()
    label.draw()

def on_key_press(symbol, modifiers):
    print "HANDLER A", symbol
window.push_handlers(on_key_press)

def registerHandlerWithDecorator():
        @window.event
        def on_key_press(symbol, modifiers):
            print "HANDLER B", symbol

def registerHandlerWithPush():
        def on_key_press(symbol, modifiers):
            print "HANDLER C", symbol
        window.push_handlers(on_key_press)


registerHandlerWithDecorator()
registerHandlerWithPush()

pyglet.app.run()
##########################################
--~--~---------~--~----~------------~-------~--~----~
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