#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Wed, 27 Jun 2018 17:18:08 +0200
changeset 8419 007fbbf55ed9
parent 8418 ad6468bab490
child 8421 187ce2842f8c
#FEATURE by cg class: WindowGroup class definition added: #controlInterruptHandler: changed: #eventLoopWhile:onLeave: hook to allow halt/breakpoit filtering
WindowGroup.st
--- a/WindowGroup.st	Fri Jun 22 12:02:40 2018 +0200
+++ b/WindowGroup.st	Wed Jun 27 17:18:08 2018 +0200
@@ -20,7 +20,7 @@
 		busyHookTimeout inModalLoop isDebugged preEventHooks
 		postEventHooks creatingProcess traceEvents processPriority
 		inWithCursorDoBlock doNotCloseOnAbortSignal previousFocusView
-		modalGroup'
+		modalGroup controlInterruptHandler'
 	classVariableNames:'LastActiveGroup LastActiveProcess LeaveSignal BusyHookTime'
 	poolDictionaries:''
 	category:'Interface-Support-UI'
@@ -748,6 +748,17 @@
     busyHookTimeout := anObject
 !
 
+controlInterruptHandler:aHandlerBlock
+    "can be used to intercept control interrupts
+     (breakpoints and halts) on a per windowGroup base.
+     If set, it gets called like an exception handler 
+     (i.e. with optional ex argument, which can be rejected, resumed, etc.)"
+
+    controlInterruptHandler := aHandlerBlock
+
+    "Created: / 27-06-2018 / 16:59:09 / Claus Gittinger"
+!
+
 postEventHook 
     "return the postEventHook if any.
      That is a backwardCompatibility leftOver - no multiple hooks are supported."
@@ -1364,7 +1375,8 @@
 !
 
 eventLoopWhile:aBlock onLeave:cleanupActions
-    "wait-for and process events.
+    "this is the main event loop in which application sits:
+     wait-for and process events.
      Stay in this loop while there are still any views to dispatch for,
      and aBlock evaluates to true.
 
@@ -1378,7 +1390,8 @@
 
     signalsToHandle := SignalSet
                            with:LeaveSignal 
-                           with:ActivityNotification.
+                           with:ActivityNotification
+                           with:ControlInterrupt.
 
     (isModal not or:[AbortAllOperationRequest isHandled not]) ifTrue:[
         signalsToHandle add:AbortAllOperationRequest
@@ -1462,11 +1475,18 @@
                         self closeDownViews.    
                         ^ self
                     ].
-
+                    (ControlInterrupt accepts:theSig) ifTrue:[
+                        controlInterruptHandler isNil ifTrue:[
+                            ex reject.
+                        ].    
+                        controlInterruptHandler valueWithOptionalArgument:ex.
+                        ex resume.
+                    ].    
+                    
                     "/ ActivityNotification
                     "/
                     "/ if I am a modal-group, let it be handled
-                    "/ by the outer main-groups handler (but only if there is one)
+                    "/ by the outer main-group's handler (but only if there is one)
                     "/ otherwise show the activityMessage and continue.
                     "/
                     isModal ifTrue:[
@@ -1553,6 +1573,7 @@
 
     "Modified: / 06-07-2010 / 11:47:27 / cg"
     "Modified (comment): / 11-04-2018 / 11:30:52 / stefan"
+    "Modified: / 27-06-2018 / 17:02:18 / Claus Gittinger"
 !
 
 executePostEventHooksFor:anEvent