KeybdMap.st
changeset 89 ea2bf46eb669
parent 72 3e84121988c3
child 219 9ff0660f447f
--- a/KeybdMap.st	Mon Feb 06 01:30:10 1995 +0100
+++ b/KeybdMap.st	Mon Feb 06 01:38:04 1995 +0100
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1993 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libview/Attic/KeybdMap.st,v 1.5 1994-10-10 02:32:37 claus Exp $
+$Header: /cvs/stx/stx/libview/Attic/KeybdMap.st,v 1.6 1995-02-06 00:37:29 claus Exp $
 '!
 
 !KeyboardMap class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libview/Attic/KeybdMap.st,v 1.5 1994-10-10 02:32:37 claus Exp $
+$Header: /cvs/stx/stx/libview/Attic/KeybdMap.st,v 1.6 1995-02-06 00:37:29 claus Exp $
 "
 !
 
@@ -50,33 +50,67 @@
 "
     instances of KeyboardMap are used for mapping keystrokes AND sequences
     of keystrokes to a function key.
-    There is usually only one instance in the system - hold in Display.
-    The setup of this map is usually done in the smalltalk.rc or one of the
-    display.rc files during startup.
+    There is usually only one instance in the system - held in an instance
+    variable of Display.
+
+    The setup of this map is done in the 'smalltalk.rc' or one of the
+    'display.rc' files during startup.
+    To add a mapping (for example, to attach the logical function 'DoIt' to
+    the key-combination Cmd-'d'):
+
+	|m|
+
+	m := Display keyboardMap.
+	m bindValue:#DoIt to:#Cmdd.
+
+    Key sequences can also be defined (hey emacs fans ;-) as in:
+
+	|m|
+
+	m := Display keyboardMap.
+	m bindValue:#DoIt to:#Ctrlx followedBy:#Ctrld
+
+    Key prefixes are defined in the DeviceWorkstation>>translateKey: method.
+    Typical prefixes are Cmd (for Alt or Meta), Ctrl etc.
+    Some keyboards offer both Alt and Meta keys - on those, the first has a
+    prefix of Alt, the second has Cmd as prefix. Keyboards with only an Alt
+    key will will create prefix codes of Cmd for that.
+
+    To remove a mapping, use the same value for both logical and physical key,
+    as in:
+
+	|m|
+
+	m := Display keyboardMap.
+	m bindValue:#Cmdd to:#Cmdd.
 "
 ! !
 
 !KeyboardMap methodsFor:'accessing'!
 
-bindValue:anObject to:aKey
-    self at:aKey put:anObject
+bindValue:logicalKey to:aKey
+    aKey == logicalKey ifTrue:[
+	self removeKey:aKey
+    ] ifFalse:[
+	self at:aKey put:logicalKey
+    ]
 !
 
-bindValue:anObject to:key1 followedBy:key2
+bindValue:logicalKey to:key1 followedBy:key2
     |submap|
 
-    submap := self at:key1.
+    submap := self at:key1 ifAbsent:[].
     submap isNil ifTrue:[
 	submap := KeyboardMap new.
 	self at:key1 put:submap.
     ].
-    submap at:key2 put:anObject
+    submap at:key2 put:logicalKey
 !
 
 valueFor:aKey
     |where value|
 
-    where := current notNil ifTrue:[current] ifFalse:[self].
+    where := (current notNil ifTrue:[current] ifFalse:[self]).
 
     value := where at:aKey ifAbsent:aKey.
     (value isMemberOf:KeyboardMap) ifTrue:[