tuikit/core/signal.py
changeset 109 105b1affc3c2
parent 86 0978fb755d31
--- a/tuikit/core/signal.py	Fri Mar 28 19:58:59 2014 +0100
+++ b/tuikit/core/signal.py	Wed Sep 03 19:08:21 2014 +0200
@@ -15,13 +15,19 @@
 
     """
 
-    def __init__(self):
+    def __init__(self, allow_stop=False):
         self._handlers = []
+        #: Allow one of the handlers to stop processing signal
+        #: The handler should return True value,
+        #: then other handlers will not be called
+        self.allow_stop = allow_stop
 
     def __call__(self, *args, **kwargs):
         """Emit the signal to all connected handlers."""
         for handler in self._handlers:
-            handler(*args, **kwargs)
+            res = handler(*args, **kwargs)
+            if self.allow_stop and res:
+                return True
 
     def connect(self, handler):
         if not handler in self._handlers: