KeyboardProcessor.st
changeset 1124 3dc83be3a3f9
child 1128 7810bca304e3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/KeyboardProcessor.st	Tue Mar 09 17:40:36 1999 +0100
@@ -0,0 +1,171 @@
+"
+ COPYRIGHT (c) 1997 by eXept Software AG
+              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.
+"
+
+
+
+
+
+Object subclass:#KeyboardProcessor
+	instanceVariableNames:'returnIsOKInDialog escapeIsCancelInDialog menuBar'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Interface-Support-UI'
+!
+
+!KeyboardProcessor class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1997 by eXept Software AG
+              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
+"
+    ST80 compatibility (mimicry) class.
+
+    The class is not completed yet and certainly not bug free.
+    Also, it is not guaranteed that all winSpecs are understood.
+
+    Notice: 
+        this class was implemented using protocol information
+        from alpha testers, literature and by reading public domain code
+        - it may not be complete or compatible to
+        the corresponding ST-80 class. 
+        If you encounter any incompatibilities, please forward a note 
+        describing the incompatibility verbal (i.e. no code) to the ST/X team.
+
+    [author:]
+        Claus Atzkern
+"
+
+
+
+
+! !
+
+!KeyboardProcessor methodsFor:'ST80 - mimicri'!
+
+keyboardConsumers
+    ^ #()
+
+    "Created: 6.3.1997 / 15:16:32 / cg"
+!
+
+removeKeyboardReceiver:aController
+
+    "Created: / 31.10.1997 / 01:56:54 / cg"
+!
+
+sendKeyboardTo:aController
+
+    "Created: / 31.10.1997 / 01:57:15 / cg"
+!
+
+setActive:aWidget
+
+    "Created: 3.3.1997 / 18:31:09 / cg"
+! !
+
+!KeyboardProcessor methodsFor:'accessing'!
+
+escapeIsCancelInDialog:aBoolean
+    escapeIsCancelInDialog := aBoolean
+!
+
+menuBar
+    "return the value of the instance variable 'menuBar' (automatically generated)"
+
+    ^ menuBar!
+
+menuBar:something
+    "set the value of the instance variable 'menuBar' (automatically generated)"
+
+    menuBar := something.!
+
+returnIsOKInDialog:aBoolean
+    returnIsOKInDialog := aBoolean
+
+! !
+
+!KeyboardProcessor methodsFor:'event handling'!
+
+processEvent:event
+    |key topView app view|
+
+    view := event view.
+
+    event isKeyPressEvent ifTrue:[
+        key := event key.
+        topView := view topView.
+        app := topView application.
+
+        topView isModal ifTrue:[
+            (returnIsOKInDialog and:[key == #Return]) ifTrue:[
+                app doAccept.
+                ^ self
+            ].
+            (escapeIsCancelInDialog and:[key == #Escape]) ifTrue:[
+                app doCancel.
+                ^ self
+            ].
+        ].
+
+        "/ how about menu-shortkeys ?
+        (menuBar notNil and:[(menuBar processShortcutKeyEventInMenuBar:event)]) ifTrue:[
+            ^ self
+        ]
+    ].
+
+    view dispatchEvent:event
+
+    "/ let view dispatch it.
+
+
+
+!
+
+requestForWindowClose
+     "about to close the window.
+      If autoAccept is true, check for this, and only return true if all
+      fields agree."
+
+    ^ self requestGlobalAutoAccept
+
+!
+
+requestGlobalAutoAccept
+     "about to close the window.
+      If autoAccept is true, check for this, and only return true if all
+      fields agree."
+
+    ^ true
+
+! !
+
+!KeyboardProcessor class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /cvs/stx/stx/libview2/KeyboardProcessor.st,v 1.1 1999-03-09 16:40:36 cg Exp $'
+! !