def decorate(func): func.selectors = [ Selector.from_string(r.strip()) for r in rule.split(',') ] if event_name is not None: func.event_name = event_name return func
def decorate(func): func.selectors = [Selector.from_string(r.strip()) for r in rule.split(',')] if event_name is not None: func.event_name = event_name self.push_handlers(func) return func
def select(rule): selector = Selector.from_string(rule) def decorate(func): func.selector = selector return func return decorate
def decorate(func): name = event_name or func.__name__ if name not in GUIEventDispatcher.event_types: raise EventException('Unknown event "%s"' % name) for r in rule.split(','): selector = Selector.from_string(r.strip()) GUIEventDispatcher.set_default_handler(name, selector, func) return func
handler.selector = universal_selector ruleset.add_rule(handler) def dispatch_event(self, element, event_type, *args): for frame in self._event_stack: ruleset = frame.get(event_type, None) if ruleset: handlers = ruleset.get_matching_rules(element) for handler in handlers: ret = handler(element, *args) if ret != EVENT_UNHANDLED: return True LayoutEventDispatcher.register_event_type('on_mouse_press') LayoutEventDispatcher.register_event_type('on_mouse_enter') LayoutEventDispatcher.register_event_type('on_mouse_leave') def select(rule): selector = Selector.from_string(rule) def decorate(func): func.selector = selector return func return decorate universal_selector = Selector(SimpleSelector(None, None, (), (), ()), ())