This may seem like a dumb question but trying to understand the point of
the custom event dispatcher. Looking at the example:
class ClankingWidget(pyglet.event.EventDispatcher):
def clank(self):
self.dispatch_event('on_clank')
def click(self, clicks):
self.dispatch_event('on_clicked', clicks)
def on_clank(self):
print 'Default clank handler.'
ClankingWidget.register_event_type('on_clank')
ClankingWidget.register_event_type('on_clicked')
widget = ClankingWidget()
@widget.event
def on_clank():
pass
@widget.event
def on_clicked(clicks):
pass
def override_on_clicked(clicks):
pass
widget.push_handlers(on_clicked=override_on_clicked)
Is this just a way to do some sort of inheritance? What is the benefit of
going through the event system as opposed to Widget being its own class
with its own clank or on_clank method? For instance instead of having
on_clank at all, just have clank and any 'widgets' that need to use it will
have their own clank method. I understand the 'publisher/subscriber' case
where the EventDispatcher is the caller or some sort of controller, and the
handlers are the 'observers', but not sure how in what cases this works in
reverse.
Can someone explain this in a little more detail and some example of how it
would be used in a game?
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.