# HG changeset patch # User phoku@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1224312381 0 # Node ID 81a222e7bd2574e17d6f906a5d43ac25549bef72 # Parent fbc55c6f57cfe608de33d884ef0d0c9ffaf7b0b7 Fixes for event handling. diff -r fbc55c6f57cf -r 81a222e7bd25 engine/extensions/pychan/events.py --- a/engine/extensions/pychan/events.py Wed Oct 15 18:04:52 2008 +0000 +++ b/engine/extensions/pychan/events.py Sat Oct 18 06:46:21 2008 +0000 @@ -168,8 +168,10 @@ raise exceptions.RuntimeError("Unknown eventname: " + event_name) if callback is None: - if self.isCaptured(event_name): + if self.isCaptured(event_name,group_name): del self.listener.events[event_name][group_name] + if not self.listener.events[event_name]: + del self.listener.events[event_name] if not self.listener.events: self.detach() elif self.debug: @@ -188,7 +190,7 @@ self.listener.events[event_name][group_name] = captured_f self.attach() - def isCaptured(self,event_name,group_name): + def isCaptured(self,event_name,group_name="default"): return event_name in self.listener.events and group_name in self.listener.events[event_name] def getCapturedEvents(self): diff -r fbc55c6f57cf -r 81a222e7bd25 engine/extensions/pychan/widgets.py --- a/engine/extensions/pychan/widgets.py Wed Oct 15 18:04:52 2008 +0000 +++ b/engine/extensions/pychan/widgets.py Sat Oct 18 06:46:21 2008 +0000 @@ -644,6 +644,10 @@ Callback is called when mouse enters the area of Widget callback should have form of function(button) """ + if cb is None: + self.capture(None, event_name = "mouseEntered" ) + return + def callback(widget=None): return cb(widget) print "PyChan: You are using the DEPRECATED functionality: setEnterCallback." @@ -656,6 +660,10 @@ Callback is called when mouse exits the area of Widget callback should have form of function(button) """ + if cb is None: + self.capture(None, event_name = "mouseExited" ) + return + def callback(widget=None): return cb(widget) print "PyChan: You are using the DEPRECATED functionality: setExitCallback."