PopUpView.st
changeset 3088 79259d26e59e
parent 2876 dbe1454f8539
child 3154 2c9c64a64c20
--- a/PopUpView.st	Wed Dec 08 21:31:48 1999 +0100
+++ b/PopUpView.st	Wed Dec 08 21:39:03 1999 +0100
@@ -11,7 +11,8 @@
 "
 
 TopView subclass:#PopUpView
-	instanceVariableNames:'shadowView haveControl exclusivePointer mapTime'
+	instanceVariableNames:'shadowView haveControl exclusivePointer mapTime
+		previousPointerGrab previousKeyboardGrab'
 	classVariableNames:'DefaultShadow DefaultLevel DefaultBorderWidth DefaultBorderColor'
 	poolDictionaries:''
 	category:'Views-Basic'
@@ -186,6 +187,62 @@
     "Created: / 4.12.1998 / 15:11:20 / cg"
 ! !
 
+!PopUpView methodsFor:'grabbing'!
+
+forceUngrabKeyboard
+'PopUpView [warning]: forceUngrabKeyboard should no longer be invoked' errorPrint.
+"/ Transcript show:'k-uuu forced by '; show:self; show:'[',self identityHash printString,']'; showCR:' - previous is ' , previousKeyboardGrab printString.
+"/ self halt.
+    super forceUngrabKeyboard.
+
+
+!
+
+forceUngrabPointer
+'PopUpView [warning]: forceUngrabPointer should no longer be invoked' errorPrint.
+"/ Transcript show:'uuu forced by '; show:self; show:'[',self identityHash printString,']'; showCR:' - previous is ' , previousPointerGrab printString.
+"/ self halt.
+    super forceUngrabPointer.
+
+
+!
+
+grabKeyboard
+    previousKeyboardGrab := device activeKeyboardGrab.
+"/ Transcript show:'k-ggg by '; show:self; show:'[',self identityHash printString,']'; showCR:' - previous is ' , previousKeyboardGrab printString.
+    ^ super grabKeyboard
+
+
+!
+
+grabPointerWithCursor:aCursorOrNil
+    previousPointerGrab := device activePointerGrab.
+"/ Transcript show:'ggg by '; show:self; show:'[',self identityHash printString,']'; showCR:' - previous is ' , previousPointerGrab printString.
+    ^ super grabPointerWithCursor:aCursorOrNil
+
+
+!
+
+ungrabKeyboard
+"/ Transcript show:'k-uuu by '; show:self; show:'[',self identityHash printString,']'; showCR:' - previous is ' , previousKeyboardGrab printString.
+    super ungrabKeyboard.
+    previousKeyboardGrab notNil ifTrue:[
+        device grabKeyboardInView:previousKeyboardGrab
+    ].
+
+
+!
+
+ungrabPointer
+"/ Transcript show:'uuu by '; show:self; show:'[',self identityHash printString,']'; showCR:' - previous is ' , previousPointerGrab printString.
+    super ungrabPointer.
+    previousPointerGrab notNil ifTrue:[
+        device grabPointerInView:previousPointerGrab
+    ].
+
+
+! !
+
 !PopUpView methodsFor:'initialize / release'!
 
 create
@@ -251,12 +308,8 @@
 releasePointerAndKeyboard 
     "release the pointer and keyboard"
 
-    device activePointerGrab == self ifTrue:[
-        device ungrabPointer.
-    ].
-    device activeKeyboardGrab == self ifTrue:[
-        device ungrabKeyboard.
-    ].
+    self ungrabPointer.
+    self ungrabKeyboard.
 ! !
 
 !PopUpView methodsFor:'private'!
@@ -264,14 +317,10 @@
 regainControl
     "get exclusive access to pointer and keyboard"
 
-    |sensor|
-
     shown ifTrue:[
-        device grabPointerInView:self.
-        device grabKeyboardInView:self.
-
-        self sensor flushMotionEventsFor:nil.
-        self sensor flushKeyboardFor:nil.
+        self grabPointer.
+        self grabKeyboard.
+        self sensor flushMotionEventsFor:nil; flushKeyboardFor:nil.
     ].
 
     "Modified: 6.5.1996 / 22:33:39 / stefan"
@@ -336,11 +385,11 @@
     (haveControl 
     and:[true "/ exclusivePointer
     and:[realized]]) ifTrue:[
-        (device grabPointerInView:self) ifFalse:[
+        (self grabPointer) ifFalse:[
             "wait a little bit and try again"
 "/            'grab pointer failed' errorPrintNL.
             Delay waitForSeconds:0.1.
-            (device grabPointerInView:self) ifFalse:[
+            (self grabPointer) ifFalse:[
                 "give up"
                 'PopUpView [warning]: could not grab pointer' errorPrintCR.
                 self unmap
@@ -349,7 +398,7 @@
         exclusivePointer ifFalse:[
             self releasePointer
         ].
-        device grabKeyboardInView:self.
+        self grabKeyboard.
         self getKeyboardFocus
     ]
 
@@ -381,5 +430,5 @@
 !PopUpView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/PopUpView.st,v 1.42 1999-08-31 15:58:10 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/PopUpView.st,v 1.43 1999-12-08 20:39:03 ca Exp $'
 ! !