changeset 166:81a222e7bd25

Fixes for event handling.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 18 Oct 2008 06:46:21 +0000
parents fbc55c6f57cf
children 10a5f9e6c03f
files engine/extensions/pychan/events.py engine/extensions/pychan/widgets.py
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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):
--- 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."