Esempio n. 1
0
 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
Esempio n. 2
0
 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
Esempio n. 3
0
def select(rule):
    selector = Selector.from_string(rule)

    def decorate(func):
        func.selector = selector
        return func

    return decorate
Esempio n. 4
0
 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
Esempio n. 5
0
 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
Esempio n. 6
0
            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, (), (), ()), ())
Esempio n. 7
0
def select(rule):
    selector = Selector.from_string(rule)
    def decorate(func):
        func.selector = selector
        return func
    return decorate