sorry, replace event_handler_instance. with event_dispatcher_instance.
On Tue, Mar 10, 2015 at 10:52 PM, claudio canepa <ccanep...@gmail.com> wrote: > > > On Tue, Mar 10, 2015 at 6:09 PM, Brandon Keith Biggs < > brandonkeithbi...@gmail.com> wrote: > >> Hello, >> I can't quite figure out how this class works. >> I see under remove_handler: >> The given event handler is removed from the first handler stack frame it >> appears in. >> OK, so the stack is split into frames? How do I make one of the frames? >> > > Each event_handler_instance.push_handlers(...) creates a frame > > When I make a frame, can I add several objects with the same event type? >> Like 3 screen objects with the on_key_press method? >> > > No. Each frame accepts only one handler per event. > So, for 3 screen objects that want to handle on_key_press, you need three > frames, by example with > window.push_handlers(on_key_press=obj1.on_key_press) > window.push_handlers(on_key_press=obj2.on_key_press) > window.push_handlers(on_key_press=obj3.on_key_press) > > Last pushed will be called first by pyglet. > > The return of each handler will tell pyglet if the event needs further > propagation > > >> How do I remove an item from that frame? >> > > You cannot specify the frame for deletions. The stack will be inspected > from the top searching for a match; first match will be deleted. > Following the prev example, you can do > > window.remove_handler("on_key_press", obj2.on_key_press) > > that will remove the obvious handler from the second frame in the stack. > > How do I remove the whole frame, even though there may be several items on >> that frame? >> > > event_handler_instance.pop_handlers() will remove the top frame in the > stack > > >> What is the difference between push_handlers and set_handlers? >> > > push_handlers creates a frame in the top of the stack, and if any handler > was specified they are added to this newly created frame. > > set_handlers adds / replaces handlers into the frame at the top of the > stack (if the stack is empty it creates a new frame) > > >> Sorry, but the documentation is not very clear and creating >> screens/frames is how I like to layout my games. >> thanks, >> >> -- >> <http://www.brandonkeithbiggs.com/> >> > > hth > > -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscr...@googlegroups.com. To post to this group, send email to pyglet-users@googlegroups.com. Visit this group at http://groups.google.com/group/pyglet-users. For more options, visit https://groups.google.com/d/optout.