equal
deleted
inserted
replaced
12 import inspect |
12 import inspect |
13 |
13 |
14 |
14 |
15 class Event: |
15 class Event: |
16 def __init__(self): |
16 def __init__(self): |
|
17 self.event_name = None |
17 self.originator = None |
18 self.originator = None |
18 |
19 |
19 def __getitem__(self, key): |
20 def __getitem__(self, key): |
20 return self.__dict__[key] |
21 return self.__dict__[key] |
21 |
22 |
60 self.y = y |
61 self.y = y |
61 self.wx = x # local widget coordinates |
62 self.wx = x # local widget coordinates |
62 self.wy = y |
63 self.wy = y |
63 self.px = 0 # parent coordinates |
64 self.px = 0 # parent coordinates |
64 self.py = 0 |
65 self.py = 0 |
|
66 #: Mouse button: left=1, middle=2, right=3, wheelup=4 wheeldown=5 |
65 self.button = button |
67 self.button = button |
66 |
68 |
67 def childevent(self, child): |
69 def childevent(self, child): |
68 ev = MouseEvent(self.x, self.y, self.button) |
70 ev = MouseEvent(self.x, self.y, self.button) |
69 # original local coordinates are new parent coordinates |
71 # original local coordinates are new parent coordinates |
192 event = args[0] |
194 event = args[0] |
193 else: |
195 else: |
194 event = self._event_class[event_name](*args, **kwargs) |
196 event = self._event_class[event_name](*args, **kwargs) |
195 # set originator to instance on which emit() was called |
197 # set originator to instance on which emit() was called |
196 event.originator = self |
198 event.originator = self |
|
199 event.event_name = event_name |
197 # call handlers from first to last, stop if satisfied |
200 # call handlers from first to last, stop if satisfied |
198 for handler in self._event_handlers[event_name]: |
201 for handler in self._event_handlers[event_name]: |
199 handled = handler(event) |
202 handled = handler(event) |
200 if handled: |
203 if handled: |
201 return True |
204 return True |