focus handling changed.
authorClaus Gittinger <cg@exept.de>
Sun, 14 Mar 1999 14:01:00 +0100
changeset 2506 221b75206a75
parent 2505 b17657563552
child 2507 daaf44f27cdd
focus handling changed.
KeybdFwd.st
KeyboardForwarder.st
SimpleView.st
StandardSystemView.st
StdSysV.st
WGroup.st
WindowGroup.st
--- a/KeybdFwd.st	Sat Mar 13 14:10:51 1999 +0100
+++ b/KeybdFwd.st	Sun Mar 14 14:01:00 1999 +0100
@@ -398,6 +398,16 @@
 
 !KeyboardForwarder methodsFor:'focus forwarding'!
 
+hasKeyboardFocus:aBoolean
+    "forward focus information to my destination"
+
+    destinationView notNil ifTrue:[
+        destinationView hasKeyboardFocus:aBoolean
+    ].
+
+    "Modified: 25.2.1997 / 23:16:35 / cg"
+!
+
 showFocus:explicit
     "forward focus information to my destination"
 
@@ -486,5 +496,5 @@
 !KeyboardForwarder class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/KeybdFwd.st,v 1.23 1998-05-20 23:56:12 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/KeybdFwd.st,v 1.24 1999-03-14 13:00:11 cg Exp $'
 ! !
--- a/KeyboardForwarder.st	Sat Mar 13 14:10:51 1999 +0100
+++ b/KeyboardForwarder.st	Sun Mar 14 14:01:00 1999 +0100
@@ -398,6 +398,16 @@
 
 !KeyboardForwarder methodsFor:'focus forwarding'!
 
+hasKeyboardFocus:aBoolean
+    "forward focus information to my destination"
+
+    destinationView notNil ifTrue:[
+        destinationView hasKeyboardFocus:aBoolean
+    ].
+
+    "Modified: 25.2.1997 / 23:16:35 / cg"
+!
+
 showFocus:explicit
     "forward focus information to my destination"
 
@@ -486,5 +496,5 @@
 !KeyboardForwarder class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/KeyboardForwarder.st,v 1.23 1998-05-20 23:56:12 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/KeyboardForwarder.st,v 1.24 1999-03-14 13:00:11 cg Exp $'
 ! !
--- a/SimpleView.st	Sat Mar 13 14:10:51 1999 +0100
+++ b/SimpleView.st	Sun Mar 14 14:01:00 1999 +0100
@@ -4494,38 +4494,22 @@
 !
 
 focusIn
-    "got keyboard focus (via the window manager)"
-
-    delegate notNil ifTrue:[
-	(delegate respondsTo:#handlesKeyPress:inView:) ifTrue:[
-	    (delegate handlesKeyPress:#Any inView:self) ifTrue:[
-		delegate showFocus:false.
-		^ self
-	    ]
-	]
-    ].
-    self showFocus:false
-
-    "Modified: 28.2.1997 / 23:29:12 / cg"
+    "got keyboard focus (via the window manager).
+     Nothing done here"
+
 !
 
 focusOut
-    "lost keyboard focus (via the window manager)"
-
-    delegate notNil ifTrue:[
-	(delegate respondsTo:#handlesKeyPress:inView:) ifTrue:[
-	    (delegate handlesKeyPress:#Any inView:self) ifTrue:[
-		delegate showNoFocus:false.
-		^ self
-	    ]
-	]
-    ].
-    self showNoFocus:false
-
-    "Modified: 28.2.1997 / 23:29:23 / cg"
+    "lost keyboard focus (via the window manager).
+     Nothing done here"
 !
 
 hasKeyboardFocus:aBoolean
+    "notification from the windowGroup that I got the keyboardFocus."
+
+    delegate notNil ifTrue:[
+        delegate perform:#hasKeyboardFocus: with:aBoolean ifNotUnderstood:nil
+    ].
     ^ self
 !
 
@@ -4639,17 +4623,15 @@
 !
 
 pointerEnter:state x:x y:y
-    "got mouse pointer"
-
-    self focusIn
+    "got mouse pointer.
+     Nothing done here"
 
     "Modified: 25.2.1997 / 23:43:21 / cg"
 !
 
 pointerLeave:state
-    "got mouse pointer"
-
-    self focusOut
+    "got mouse pointer.
+     Nothing done here"
 
     "Modified: 25.2.1997 / 23:43:17 / cg"
 !
@@ -4858,6 +4840,89 @@
     "Modified: / 10.6.1998 / 17:28:16 / cg"
 ! !
 
+!SimpleView methodsFor:'focus handling'!
+
+requestFocus
+    "request focus from my windowGroup;
+     typically, this is invoked when the mouse pointer enters a
+     widget. The request may or may not be ignored by the wGroup
+     (it will be ignored, if an explicit focus-change is currently
+      active - i.e. if the user tabbed into a widget)"
+
+    windowGroup notNil ifTrue:[
+        ^ windowGroup focusRequestFrom:self
+    ].
+    ^ true
+!
+
+showFocus:explicit
+    "highlight myself somehow to tell user that I have the focus.
+     If explicit is true, the focus came via focusStepping (i.e. tabbing);
+     if false, it came via the window manager (i.e. pointer entering).
+     Only change my border, if this is an explicit focusChange."
+
+    |delta clrId|
+
+    explicit ifTrue:[
+        drawableId notNil ifTrue:[
+            (styleSheet at:#'focus.showBorder' default:true) ifTrue:[
+                delta := DefaultFocusBorderWidth - borderWidth.
+                delta ~~ 0 ifTrue:[
+                    device moveWindow:drawableId x:left-delta y:top-delta.
+                    device setWindowBorderWidth:DefaultFocusBorderWidth in:drawableId.
+                ].
+
+                clrId := (DefaultFocusColor on:device) colorId.
+                clrId isNil ifTrue:[
+                    clrId := device blackpixel
+                ].
+                device setWindowBorderColor:clrId in:drawableId.
+            ]
+        ]
+    ] ifFalse:[
+        superView notNil ifTrue:[
+            superView showFocus:explicit
+        ]
+    ]
+
+    "Modified: / 17.9.1998 / 15:08:34 / cg"
+!
+
+showNoFocus:explicit
+    "undo the effect of showFocus.
+     Explicit tells if the focus came via focusStepping (i.e. tabbing)
+     or via the window manager (i.e. pointer entering).
+     Only change my border, if this is an explicit focusChange."
+
+    |delta|
+
+    explicit ifTrue:[
+        drawableId notNil ifTrue:[
+            (windowGroup notNil
+            and:[windowGroup focusView == self]) ifTrue:[
+                (styleSheet at:#'focus.showBorder' default:true) ifTrue:[
+                    delta := DefaultFocusBorderWidth - borderWidth.
+                    delta ~~ 0 ifTrue:[
+                        device setWindowBorderWidth:borderWidth in:drawableId.
+                        device moveWindow:drawableId x:left y:top.
+                    ].
+                    self setBorderColor.
+                ]
+            ]
+        ]
+    ]
+
+    "Modified: / 17.9.1998 / 15:08:02 / cg"
+!
+
+wantsFocusWithButtonPress
+    "views which like to take the keyboard focus
+     with buttonPress can do so by redefining this
+     to return true"
+
+    ^ false
+! !
+
 !SimpleView methodsFor:'informing others of changes'!
 
 contentsChanged
@@ -5833,12 +5898,13 @@
     windowGroup isNil ifTrue:[^ false].
 
     (focusView := windowGroup focusView) == self ifTrue:[^ true].
+
     focusView notNil ifTrue:[
-	"mhmh - is there a delegation to me ?"
-	(delegate := focusView delegate) notNil ifTrue:[
-	    delegate == self ifTrue:[^ true].
-	    ^ delegate delegatesTo:self
-	]
+        "mhmh - is there a delegation to me ?"
+        (delegate := focusView delegate) notNil ifTrue:[
+            delegate == self ifTrue:[^ true].
+            ^ delegate delegatesTo:self
+        ]
     ].
     ^ false
 !
@@ -7031,66 +7097,6 @@
     ^ self
 !
 
-showFocus:explicit
-    "highlight myself somehow to tell user that I have the focus.
-     If explicit is true, the focus came via focusStepping (i.e. tabbing);
-     if false, it came via the window manager (i.e. pointer entering).
-     Only change my border, if this is an explicit focusChange."
-
-    |delta clrId|
-
-    explicit ifTrue:[
-        drawableId notNil ifTrue:[
-            (styleSheet at:#'focus.showBorder' default:true) ifTrue:[
-                delta := DefaultFocusBorderWidth - borderWidth.
-                delta ~~ 0 ifTrue:[
-                    device moveWindow:drawableId x:left-delta y:top-delta.
-                    device setWindowBorderWidth:DefaultFocusBorderWidth in:drawableId.
-                ].
-
-                clrId := (DefaultFocusColor on:device) colorId.
-                clrId isNil ifTrue:[
-                    clrId := device blackpixel
-                ].
-                device setWindowBorderColor:clrId in:drawableId.
-            ]
-        ]
-    ] ifFalse:[
-        superView notNil ifTrue:[
-            superView showFocus:explicit
-        ]
-    ]
-
-    "Modified: / 17.9.1998 / 15:08:34 / cg"
-!
-
-showNoFocus:explicit
-    "undo the effect of showFocus.
-     Explicit tells if the focus came via focusStepping (i.e. tabbing)
-     or via the window manager (i.e. pointer entering).
-     Only change my border, if this is an explicit focusChange."
-
-    |delta|
-
-    explicit ifTrue:[
-        drawableId notNil ifTrue:[
-            (windowGroup notNil
-            and:[windowGroup focusView == self]) ifTrue:[
-                (styleSheet at:#'focus.showBorder' default:true) ifTrue:[
-                    delta := DefaultFocusBorderWidth - borderWidth.
-                    delta ~~ 0 ifTrue:[
-                        device setWindowBorderWidth:borderWidth in:drawableId.
-                        device moveWindow:drawableId x:left y:top.
-                    ].
-                    self setBorderColor.
-                ]
-            ]
-        ]
-    ]
-
-    "Modified: / 17.9.1998 / 15:08:02 / cg"
-!
-
 showPassive
     "redraw myself as inactive (i.e. nonbusy).
      Nothing done here, but redefined in some classes."
@@ -7995,6 +8001,6 @@
 !SimpleView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.298 1999-03-10 22:31:00 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.299 1999-03-14 12:59:19 cg Exp $'
 ! !
 SimpleView initialize!
--- a/StandardSystemView.st	Sat Mar 13 14:10:51 1999 +0100
+++ b/StandardSystemView.st	Sun Mar 14 14:01:00 1999 +0100
@@ -841,32 +841,16 @@
     |v|
 
     windowGroup notNil ifTrue:[
-	(v := windowGroup focusView) notNil ifTrue:[
-	    v showFocus:false.
-	    ^ self
-	]
+        (v := windowGroup focusView) notNil ifTrue:[
+            v requestFocus.
+            ^ self
+        ]
     ].
     super focusIn
 
     "Modified: 25.2.1997 / 23:19:46 / cg"
 !
 
-focusOut
-    "the view lost keyboard focus (via the window manager)"
-
-    |v|
-
-    windowGroup notNil ifTrue:[
-	(v := windowGroup focusView) notNil ifTrue:[
-	    v showNoFocus:false.
-	    ^ self
-	]
-    ].
-    super focusOut
-
-    "Modified: 25.2.1997 / 23:19:54 / cg"
-!
-
 showActivity:someMessage
     "some activityNotification shalt be communicated to
      the user. Forward it to my application (if any).
@@ -1405,6 +1389,6 @@
 !StandardSystemView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/StandardSystemView.st,v 1.107 1999-02-13 10:32:16 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/StandardSystemView.st,v 1.108 1999-03-14 13:01:00 cg Exp $'
 ! !
 StandardSystemView initialize!
--- a/StdSysV.st	Sat Mar 13 14:10:51 1999 +0100
+++ b/StdSysV.st	Sun Mar 14 14:01:00 1999 +0100
@@ -841,32 +841,16 @@
     |v|
 
     windowGroup notNil ifTrue:[
-	(v := windowGroup focusView) notNil ifTrue:[
-	    v showFocus:false.
-	    ^ self
-	]
+        (v := windowGroup focusView) notNil ifTrue:[
+            v requestFocus.
+            ^ self
+        ]
     ].
     super focusIn
 
     "Modified: 25.2.1997 / 23:19:46 / cg"
 !
 
-focusOut
-    "the view lost keyboard focus (via the window manager)"
-
-    |v|
-
-    windowGroup notNil ifTrue:[
-	(v := windowGroup focusView) notNil ifTrue:[
-	    v showNoFocus:false.
-	    ^ self
-	]
-    ].
-    super focusOut
-
-    "Modified: 25.2.1997 / 23:19:54 / cg"
-!
-
 showActivity:someMessage
     "some activityNotification shalt be communicated to
      the user. Forward it to my application (if any).
@@ -1405,6 +1389,6 @@
 !StandardSystemView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/StdSysV.st,v 1.107 1999-02-13 10:32:16 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/StdSysV.st,v 1.108 1999-03-14 13:01:00 cg Exp $'
 ! !
 StandardSystemView initialize!
--- a/WGroup.st	Sat Mar 13 14:10:51 1999 +0100
+++ b/WGroup.st	Sun Mar 14 14:01:00 1999 +0100
@@ -13,9 +13,9 @@
 Object subclass:#WindowGroup
 	instanceVariableNames:'views topViews myProcess mySensor isModal previousGroup focusView
 		focusSequence preEventHook postEventHook pointerView
-		isForModalSubview focusByTab'
+		isForModalSubview focusByTab groupHasFocus'
 	classVariableNames:'LastActiveGroup LastActiveProcess LeaveSignal
-		WindowGroupQuerySignal LastEventQuerySignal'
+		WindowGroupQuerySignal LastEventQuerySignal FocusViewPerDisplay'
 	poolDictionaries:''
 	category:'Interface-Support'
 !
@@ -140,6 +140,18 @@
                                 
         focusSequence           defines the focus sequence
 
+        preEventHook            if non-nil, that one gets notified of incoming
+                                events BEFORE an event is dispatched.
+                                May eat events (i.e. suppress dispatch)
+                                (hook for event filters or recorders)
+
+        postEventHook           if non-nil, that one gets notified
+                                AFTER an event was dispatched.
+
+        isForModalSubView
+
+        groupHasFocus           true, if this windowGroup has the focus
+
 
     [class variables:]
         LeaveSignal             if raised, a modal box leaves (closes)
@@ -158,6 +170,9 @@
                                 The event can be asked for the view, the type
                                 of event, x/y position etc.
 
+        FocusViewPerDisplay     the view which has the focus (global - per display).
+
+
     (*) 
         due to historic reasons, many views have the controller functionality
         integrated, and handle events themself. The windowSensor takes care
@@ -188,19 +203,21 @@
 
 initialize
     LeaveSignal isNil ifTrue:[
-	LeaveSignal := (Signal new) mayProceed:true.
-	LeaveSignal nameClass:self message:#leaveSignal.
-	LeaveSignal notifierString:'unhandled leave signal'.
+        LeaveSignal := (Signal new) mayProceed:true.
+        LeaveSignal nameClass:self message:#leaveSignal.
+        LeaveSignal notifierString:'unhandled leave signal'.
 
-	WindowGroupQuerySignal := QuerySignal new.
-	WindowGroupQuerySignal nameClass:self message:#windowGroupQuerySignal.
-	WindowGroupQuerySignal notifierString:'query for windowgroup'.
+        WindowGroupQuerySignal := QuerySignal new.
+        WindowGroupQuerySignal nameClass:self message:#windowGroupQuerySignal.
+        WindowGroupQuerySignal notifierString:'query for windowgroup'.
 
-	LastEventQuerySignal := QuerySignal new.
-	LastEventQuerySignal nameClass:self message:#lastEventQuerySignal.
-	LastEventQuerySignal notifierString:'query for last event'.
+        LastEventQuerySignal := QuerySignal new.
+        LastEventQuerySignal nameClass:self message:#lastEventQuerySignal.
+        LastEventQuerySignal notifierString:'query for last event'.
     ].
 
+    FocusViewPerDisplay := IdentityDictionary new.
+
     "WindowGroup initialize"
 
     "Modified: 9.11.1996 / 17:00:53 / cg"
@@ -1241,12 +1258,14 @@
                         ].
 
                         "/
-                        "/  buttonPress events turn off explicit focus, and revert
+                        "/  buttonPress events turn off explicit focus, and reverts
                         "/  to implicit focus control
                         "/
                         (focusView notNil
                         and:[event isButtonPressEvent]) ifTrue:[
-                            self focusView:nil
+                            (evView wantsFocusWithButtonPress) ifTrue:[
+                                self focusView:evView.
+                            ]
                         ].
 
                         LastActiveGroup := self.
@@ -1439,7 +1458,7 @@
 
 focusNext
     "give focus to the next view in the focusSequence.
-     Skip invisible views."
+     Skip invisible & disabled widgets."
 
     |index     "{ Class: SmallInteger }"
      lastIndex "{ Class: SmallInteger }"
@@ -1555,6 +1574,17 @@
     "Created: / 4.8.1998 / 02:43:08 / cg"
 !
 
+focusRequestFrom:aView
+    "aView requests focus. I will grant it, if I have no explicit
+     focusView (i.e. not tabbed)"
+
+    (focusView isNil or:[focusByTab not]) ifTrue:[
+        self focusView:aView byTab:false.
+        ^ true
+    ].
+    ^ false
+!
+
 focusSequence
     "return my focus sequence for focusNext/focusPrevious.
      Focus is stepped in the order in which subviews occur in
@@ -1639,27 +1669,31 @@
 focusView:aViewOrNil byTab:focusCameViaTab
     "give focus to aViewOrNil"
 
+    |prevFocusView|
+
+    prevFocusView := FocusViewPerDisplay at:self device ifAbsent:nil.
+
+    (prevFocusView notNil 
+    and:[prevFocusView ~~ aViewOrNil]) ifTrue:[
+        prevFocusView showNoFocus:true.
+        prevFocusView hasKeyboardFocus:false.
+    ].
+    FocusViewPerDisplay at:self device put:aViewOrNil.
+
     focusView == aViewOrNil ifTrue:[
         focusView notNil ifTrue:[
             focusByTab := focusCameViaTab.
-            focusByTab ifTrue:[
-                focusView showFocus:true.
-            ].
-            focusView hasKeyboardFocus:true.
+            focusView showFocus:focusByTab.
+            aViewOrNil hasKeyboardFocus:true.
         ].
         ^ self
     ].
 
     focusView notNil ifTrue:[
         "/ lost explicit focus
-        focusView == aViewOrNil ifTrue:[^ self].
-        focusView showNoFocus:true.
-    ] ifFalse:[
-        pointerView notNil ifTrue:[
-            pointerView ~~ aViewOrNil ifTrue:[
-                "/ lost implicit focus
-                pointerView showNoFocus:false
-            ]
+        focusView == aViewOrNil ifTrue:[
+            aViewOrNil hasKeyboardFocus:true.
+            ^ self
         ].
     ].
 
@@ -1668,9 +1702,9 @@
         "/ got explicit focus
         focusByTab := focusCameViaTab.
         focusByTab ifTrue:[
-            focusView showFocus:true.
+            aViewOrNil showFocus:true.
         ].
-        focusView hasKeyboardFocus:true.
+        aViewOrNil hasKeyboardFocus:true.
     ].
 
     "
@@ -1955,6 +1989,6 @@
 !WindowGroup class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/WGroup.st,v 1.157 1999-03-11 00:42:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/WGroup.st,v 1.158 1999-03-14 12:59:42 cg Exp $'
 ! !
 WindowGroup initialize!
--- a/WindowGroup.st	Sat Mar 13 14:10:51 1999 +0100
+++ b/WindowGroup.st	Sun Mar 14 14:01:00 1999 +0100
@@ -13,9 +13,9 @@
 Object subclass:#WindowGroup
 	instanceVariableNames:'views topViews myProcess mySensor isModal previousGroup focusView
 		focusSequence preEventHook postEventHook pointerView
-		isForModalSubview focusByTab'
+		isForModalSubview focusByTab groupHasFocus'
 	classVariableNames:'LastActiveGroup LastActiveProcess LeaveSignal
-		WindowGroupQuerySignal LastEventQuerySignal'
+		WindowGroupQuerySignal LastEventQuerySignal FocusViewPerDisplay'
 	poolDictionaries:''
 	category:'Interface-Support'
 !
@@ -140,6 +140,18 @@
                                 
         focusSequence           defines the focus sequence
 
+        preEventHook            if non-nil, that one gets notified of incoming
+                                events BEFORE an event is dispatched.
+                                May eat events (i.e. suppress dispatch)
+                                (hook for event filters or recorders)
+
+        postEventHook           if non-nil, that one gets notified
+                                AFTER an event was dispatched.
+
+        isForModalSubView
+
+        groupHasFocus           true, if this windowGroup has the focus
+
 
     [class variables:]
         LeaveSignal             if raised, a modal box leaves (closes)
@@ -158,6 +170,9 @@
                                 The event can be asked for the view, the type
                                 of event, x/y position etc.
 
+        FocusViewPerDisplay     the view which has the focus (global - per display).
+
+
     (*) 
         due to historic reasons, many views have the controller functionality
         integrated, and handle events themself. The windowSensor takes care
@@ -188,19 +203,21 @@
 
 initialize
     LeaveSignal isNil ifTrue:[
-	LeaveSignal := (Signal new) mayProceed:true.
-	LeaveSignal nameClass:self message:#leaveSignal.
-	LeaveSignal notifierString:'unhandled leave signal'.
+        LeaveSignal := (Signal new) mayProceed:true.
+        LeaveSignal nameClass:self message:#leaveSignal.
+        LeaveSignal notifierString:'unhandled leave signal'.
 
-	WindowGroupQuerySignal := QuerySignal new.
-	WindowGroupQuerySignal nameClass:self message:#windowGroupQuerySignal.
-	WindowGroupQuerySignal notifierString:'query for windowgroup'.
+        WindowGroupQuerySignal := QuerySignal new.
+        WindowGroupQuerySignal nameClass:self message:#windowGroupQuerySignal.
+        WindowGroupQuerySignal notifierString:'query for windowgroup'.
 
-	LastEventQuerySignal := QuerySignal new.
-	LastEventQuerySignal nameClass:self message:#lastEventQuerySignal.
-	LastEventQuerySignal notifierString:'query for last event'.
+        LastEventQuerySignal := QuerySignal new.
+        LastEventQuerySignal nameClass:self message:#lastEventQuerySignal.
+        LastEventQuerySignal notifierString:'query for last event'.
     ].
 
+    FocusViewPerDisplay := IdentityDictionary new.
+
     "WindowGroup initialize"
 
     "Modified: 9.11.1996 / 17:00:53 / cg"
@@ -1241,12 +1258,14 @@
                         ].
 
                         "/
-                        "/  buttonPress events turn off explicit focus, and revert
+                        "/  buttonPress events turn off explicit focus, and reverts
                         "/  to implicit focus control
                         "/
                         (focusView notNil
                         and:[event isButtonPressEvent]) ifTrue:[
-                            self focusView:nil
+                            (evView wantsFocusWithButtonPress) ifTrue:[
+                                self focusView:evView.
+                            ]
                         ].
 
                         LastActiveGroup := self.
@@ -1439,7 +1458,7 @@
 
 focusNext
     "give focus to the next view in the focusSequence.
-     Skip invisible views."
+     Skip invisible & disabled widgets."
 
     |index     "{ Class: SmallInteger }"
      lastIndex "{ Class: SmallInteger }"
@@ -1555,6 +1574,17 @@
     "Created: / 4.8.1998 / 02:43:08 / cg"
 !
 
+focusRequestFrom:aView
+    "aView requests focus. I will grant it, if I have no explicit
+     focusView (i.e. not tabbed)"
+
+    (focusView isNil or:[focusByTab not]) ifTrue:[
+        self focusView:aView byTab:false.
+        ^ true
+    ].
+    ^ false
+!
+
 focusSequence
     "return my focus sequence for focusNext/focusPrevious.
      Focus is stepped in the order in which subviews occur in
@@ -1639,27 +1669,31 @@
 focusView:aViewOrNil byTab:focusCameViaTab
     "give focus to aViewOrNil"
 
+    |prevFocusView|
+
+    prevFocusView := FocusViewPerDisplay at:self device ifAbsent:nil.
+
+    (prevFocusView notNil 
+    and:[prevFocusView ~~ aViewOrNil]) ifTrue:[
+        prevFocusView showNoFocus:true.
+        prevFocusView hasKeyboardFocus:false.
+    ].
+    FocusViewPerDisplay at:self device put:aViewOrNil.
+
     focusView == aViewOrNil ifTrue:[
         focusView notNil ifTrue:[
             focusByTab := focusCameViaTab.
-            focusByTab ifTrue:[
-                focusView showFocus:true.
-            ].
-            focusView hasKeyboardFocus:true.
+            focusView showFocus:focusByTab.
+            aViewOrNil hasKeyboardFocus:true.
         ].
         ^ self
     ].
 
     focusView notNil ifTrue:[
         "/ lost explicit focus
-        focusView == aViewOrNil ifTrue:[^ self].
-        focusView showNoFocus:true.
-    ] ifFalse:[
-        pointerView notNil ifTrue:[
-            pointerView ~~ aViewOrNil ifTrue:[
-                "/ lost implicit focus
-                pointerView showNoFocus:false
-            ]
+        focusView == aViewOrNil ifTrue:[
+            aViewOrNil hasKeyboardFocus:true.
+            ^ self
         ].
     ].
 
@@ -1668,9 +1702,9 @@
         "/ got explicit focus
         focusByTab := focusCameViaTab.
         focusByTab ifTrue:[
-            focusView showFocus:true.
+            aViewOrNil showFocus:true.
         ].
-        focusView hasKeyboardFocus:true.
+        aViewOrNil hasKeyboardFocus:true.
     ].
 
     "
@@ -1955,6 +1989,6 @@
 !WindowGroup class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.157 1999-03-11 00:42:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.158 1999-03-14 12:59:42 cg Exp $'
 ! !
 WindowGroup initialize!