"
COPYRIGHT (c) 1993 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.
"
IdentityDictionary subclass:#KeyboardMap
instanceVariableNames:'current'
classVariableNames:''
poolDictionaries:''
category:'Interface-Support'
!
!KeyboardMap class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1993 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
"
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 - 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.
[see also:]
WindowEvent WindowSensor WindowGroup
View DeviceWorkstation
[author:]
Claus Gittinger
"
! !
!KeyboardMap methodsFor:'accessing'!
bindValue:logicalKey to:aKey
"bind aLogicalKey to a rawKey.
The event mechanism uses this to pass logical keyboard events
to the application (such as #Copy, #Cut etc.)
instead of physical ones (such as #AltC, #AltX)"
aKey == logicalKey ifTrue:[
self removeKey:aKey ifAbsent:nil
] ifFalse:[
self at:aKey put:logicalKey
]
"Modified: 12.11.1996 / 10:30:56 / cg"
!
bindValue:logicalKey to:key1 followedBy:key2
"bind aLogicalKey to a sequence of two rawKeys.
The event mechanism uses this to pass logical keyboard events
to the application (such as #Copy, #Cut etc.)
instead of physical ones (such as #AltC, #AltX)"
|submap|
submap := self at:key1 ifAbsent:[].
submap isNil ifTrue:[
submap := KeyboardMap new.
self at:key1 put:submap.
].
submap at:key2 put:logicalKey
"Modified: 23.4.1996 / 21:55:04 / cg"
!
valueFor:aKey
"retrieve a logical key"
|where value|
where := (current notNil ifTrue:[current] ifFalse:[self]).
value := where at:aKey ifAbsent:aKey.
(value isMemberOf:KeyboardMap) ifTrue:[
current := value.
^ nil.
].
current := nil.
^ value
"Modified: 23.4.1996 / 21:55:22 / cg"
! !
!KeyboardMap class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libview/Attic/KeybdMap.st,v 1.12 1996-11-12 09:41:01 cg Exp $'
! !