KeyboardForwarder.st
changeset 244 83218faf792c
parent 219 9ff0660f447f
child 251 915de9a65169
--- a/KeyboardForwarder.st	Thu Nov 23 03:29:10 1995 +0100
+++ b/KeyboardForwarder.st	Thu Nov 23 11:38:43 1995 +0100
@@ -11,8 +11,6 @@
 "
 
 
-'From Smalltalk/X, Version:2.10.5 on 30-mar-1995 at 5:32:55 am'!
-
 Object subclass:#KeyboardForwarder
 	 instanceVariableNames:'sourceView destinationView destination condition'
 	 classVariableNames:''
@@ -22,8 +20,19 @@
 
 !KeyboardForwarder class methodsFor:'documentation'!
 
-version
-    ^ '$Header: /cvs/stx/stx/libview/KeyboardForwarder.st,v 1.7 1995-11-11 15:51:36 cg Exp $'
+copyright
+"
+ COPYRIGHT (c) 1995 by Claus Gittinger
+	      All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+
 !
 
 documentation
@@ -148,33 +157,12 @@
 "
 !
 
-copyright
-"
- COPYRIGHT (c) 1995 by Claus Gittinger
-	      All Rights Reserved
-
- This software is furnished under a license and may be used
- only in accordance with the terms of that license and with the
- inclusion of the above copyright notice.   This software may not
- be provided or otherwise made available to, or used by, any
- other person.  No title to or ownership of the software is
- hereby transferred.
-"
-
+version
+    ^ '$Header: /cvs/stx/stx/libview/KeyboardForwarder.st,v 1.8 1995-11-23 10:37:44 cg Exp $'
 ! !
 
 !KeyboardForwarder class methodsFor:'instance creation'!
 
-from:sourceView toView:destinationView
-    "create and return a new KeyboardForwarder to redirect key events
-     for sourceView to destinationView. Events from other than the sourceView
-     will not be forwarded. The forwarded event will be reported excluding
-     the original view as argument (i.e. as #keyPress:x:y:). 
-     Use this, if the destination is a view."
-
-    ^ self new sourceView:sourceView; destinationView:destinationView
-!
-
 from:sourceView to:destination
     "create and return a new KeyboardForwarder to redirect key events
      for sourceView to destination. Events from other than the sourceView
@@ -185,14 +173,14 @@
     ^ self new sourceView:sourceView; destination:destination
 !
 
-toView:destinationView
-    "create and return a new KeyboardForwarder to redirect any key event
-     to destinationView (Independent of the view in which the event originally
-     occurred). The forwarded event will be reported excluding
+from:sourceView toView:destinationView
+    "create and return a new KeyboardForwarder to redirect key events
+     for sourceView to destinationView. Events from other than the sourceView
+     will not be forwarded. The forwarded event will be reported excluding
      the original view as argument (i.e. as #keyPress:x:y:). 
      Use this, if the destination is a view."
 
-    ^ self new destinationView:destinationView
+    ^ self new sourceView:sourceView; destinationView:destinationView
 !
 
 to:destination
@@ -205,6 +193,27 @@
     ^ self new destination:destination
 !
 
+to:destination condition:aCondition
+    "create and return a new KeyboardForwarder to redirect any key event
+     to destinationView (Independent of the view in which the event originally
+     occurred) but only, if some condition as specified by aCondition
+     is met. The forwarded event will be reported including
+     the original view as argument (i.e. as #keyPress:x:y:view:). 
+     Use this, if the destination is not a view."
+
+    ^ self new destination:destination; condition:aCondition
+!
+
+toView:destinationView
+    "create and return a new KeyboardForwarder to redirect any key event
+     to destinationView (Independent of the view in which the event originally
+     occurred). The forwarded event will be reported excluding
+     the original view as argument (i.e. as #keyPress:x:y:). 
+     Use this, if the destination is a view."
+
+    ^ self new destinationView:destinationView
+!
+
 toView:destinationView condition:aCondition
     "create and return a new KeyboardForwarder to redirect any key event
      to destinationView (Independent of the view in which the event originally
@@ -214,17 +223,6 @@
      Use this, if the destination is a view."
 
     ^ self new destinationView:destinationView; condition:aCondition
-!
-
-to:destination condition:aCondition
-    "create and return a new KeyboardForwarder to redirect any key event
-     to destinationView (Independent of the view in which the event originally
-     occurred) but only, if some condition as specified by aCondition
-     is met. The forwarded event will be reported including
-     the original view as argument (i.e. as #keyPress:x:y:view:). 
-     Use this, if the destination is not a view."
-
-    ^ self new destination:destination; condition:aCondition
 ! !
 
 !KeyboardForwarder methodsFor:'accessing'!
@@ -235,16 +233,10 @@
     condition := aCondition
 !
 
-destinationView:aView
-    "set the destination view"
+destination
+    "return the destination"
 
-    destinationView := aView
-!
-
-destinationView
-    "return the destination view"
-
-    ^ destinationView
+    ^ destination
 !
 
 destination:anObject 
@@ -254,61 +246,28 @@
     destination := anObject
 !
 
-destination
-    "return the destination"
+destinationView
+    "return the destination view"
 
-    ^ destination
+    ^ destinationView
 !
 
-sourceView:aView
-    "set the sourceView - if nonNil, only events from this view will be forwarded"
+destinationView:aView
+    "set the destination view"
 
-    sourceView := aView
+    destinationView := aView
 !
 
 sourceView
     "get the sourceView - if nonNil, only events from this view will be forwarded"
 
     ^ sourceView
-! !
-
-!KeyboardForwarder methodsFor:'queries'!
-
-delegatesTo:someone
-    "return true, if I delegate events to someone"
-
-    ^ destination == someone or:[destinationView == someone]
 !
 
-checkCondition:type key:key view:aView
-    condition notNil ifTrue:[
-	condition == #noFocus ifTrue:[
-	    aView windowGroup focusView notNil ifTrue:[^ false]
-	].
-	condition isBlock ifTrue:[
-	    (condition value:type value:key value:aView) ifFalse:[^ false]
-	]
-    ].
-    sourceView notNil ifTrue:[
-	^ aView == sourceView
-    ].
-    ^ true
-!
+sourceView:aView
+    "set the sourceView - if nonNil, only events from this view will be forwarded"
 
-handlesKeyPress:key inView:aView
-    "this is the query from the sensor to ask me if I would like to
-     get a keyPress event for key from aView. Return true, if I want so,
-     false otherwise."
-
-    ^ self checkCondition:#keyPress key:key view:aView
-!
-
-handlesKeyRelease:key inView:aView
-    "this is the query from the sensor to ask me if I would like to
-     get a keyRelease event for key from aView. Return true, if I want so,
-     false otherwise."
-
-    ^ self checkCondition:#keyRelease key:key view:aView
+    sourceView := aView
 ! !
 
 !KeyboardForwarder methodsFor:'event forwarding'!
@@ -360,3 +319,43 @@
 	]
     ]
 ! !
+
+!KeyboardForwarder methodsFor:'queries'!
+
+checkCondition:type key:key view:aView
+    condition notNil ifTrue:[
+	condition == #noFocus ifTrue:[
+	    aView windowGroup focusView notNil ifTrue:[^ false]
+	].
+	condition isBlock ifTrue:[
+	    (condition value:type value:key value:aView) ifFalse:[^ false]
+	]
+    ].
+    sourceView notNil ifTrue:[
+	^ aView == sourceView
+    ].
+    ^ true
+!
+
+delegatesTo:someone
+    "return true, if I delegate events to someone"
+
+    ^ destination == someone or:[destinationView == someone]
+!
+
+handlesKeyPress:key inView:aView
+    "this is the query from the sensor to ask me if I would like to
+     get a keyPress event for key from aView. Return true, if I want so,
+     false otherwise."
+
+    ^ self checkCondition:#keyPress key:key view:aView
+!
+
+handlesKeyRelease:key inView:aView
+    "this is the query from the sensor to ask me if I would like to
+     get a keyRelease event for key from aView. Return true, if I want so,
+     false otherwise."
+
+    ^ self checkCondition:#keyRelease key:key view:aView
+! !
+