Mercurial > fife-parpg
comparison engine/extensions/pychan/events.py @ 166:81a222e7bd25
Fixes for event handling.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 18 Oct 2008 06:46:21 +0000 |
parents | 5b04a7d3ded6 |
children | 06dddc96ce54 |
comparison
equal
deleted
inserted
replaced
165:fbc55c6f57cf | 166:81a222e7bd25 |
---|---|
166 def capture(self,event_name,callback,group_name): | 166 def capture(self,event_name,callback,group_name): |
167 if event_name not in EVENTS: | 167 if event_name not in EVENTS: |
168 raise exceptions.RuntimeError("Unknown eventname: " + event_name) | 168 raise exceptions.RuntimeError("Unknown eventname: " + event_name) |
169 | 169 |
170 if callback is None: | 170 if callback is None: |
171 if self.isCaptured(event_name): | 171 if self.isCaptured(event_name,group_name): |
172 del self.listener.events[event_name][group_name] | 172 del self.listener.events[event_name][group_name] |
173 if not self.listener.events[event_name]: | |
174 del self.listener.events[event_name] | |
173 if not self.listener.events: | 175 if not self.listener.events: |
174 self.detach() | 176 self.detach() |
175 elif self.debug: | 177 elif self.debug: |
176 print CALLBACK_NONE_MESSAGE % str(self.widget) | 178 print CALLBACK_NONE_MESSAGE % str(self.widget) |
177 return | 179 return |
186 self.listener.events[event_name] = {group_name : captured_f} | 188 self.listener.events[event_name] = {group_name : captured_f} |
187 else: | 189 else: |
188 self.listener.events[event_name][group_name] = captured_f | 190 self.listener.events[event_name][group_name] = captured_f |
189 self.attach() | 191 self.attach() |
190 | 192 |
191 def isCaptured(self,event_name,group_name): | 193 def isCaptured(self,event_name,group_name="default"): |
192 return event_name in self.listener.events and group_name in self.listener.events[event_name] | 194 return event_name in self.listener.events and group_name in self.listener.events[event_name] |
193 | 195 |
194 def getCapturedEvents(self): | 196 def getCapturedEvents(self): |
195 return self.listener.events.keys() | 197 return self.listener.events.keys() |
196 | 198 |