def dispatch_event(self, element, event_type, *args, **kw):
        '''Pass the event to the element.

        If propogate is True (the default) then events will propogate up
        to the element's parent.

        Since the event may be handled by a parent of the element passed
        in, we pass back the element that handled the event.
        '''
        propogate=kw.get('propogate', True)
        for frame in self._event_stack:
            ruleset = frame.get(event_type, None)
            if not ruleset: continue
            rules = ruleset.get_matching_rules(element)
            for rule in rules:
                handler = rule.declaration_set
                try:
                    ret = handler(element, *args)
                except __HOLE__, message:
                    print 'ERROR CALLING  %r (%r, *%r)]'%(handler,
                        element, args)
                    raise
                if ret != EVENT_UNHANDLED:
                    return element, EVENT_HANDLED

        # not handled, so pass the event up to parent element
        if propogate and element.parent is not None:
            return self.dispatch_event(element.parent, event_type, *args, **kw)

        return (None, EVENT_UNHANDLED)


    # EVENT HANDLER BEHAVIOR
dataset/ETHPy150Open ardekantur/pyglet/contrib/wydget/wydget/event.py/GUIEventDispatcher.dispatch_event