KeyboardMap.st
author claus
Fri, 03 Jun 1994 02:54:39 +0200
changeset 46 7b331e9012fd
parent 5 e5942fea6925
child 54 29a6b2f8e042
permissions -rw-r--r--
*** empty log message ***

"
 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 comment:'
COPYRIGHT (c) 1993 by Claus Gittinger
              All Rights Reserved
'!

!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.
"
!

version
"
$Header: /cvs/stx/stx/libview/KeyboardMap.st,v 1.3 1994-06-03 00:53:22 claus Exp $
"
!

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 - hold in Display.
    The setup of this map is usually done in the smalltalk.rc or one of the
    display.rc files during startup.
"
! !

!KeyboardMap methodsFor:'accessing'!

bindValue:anObject to:aKey
    self at:aKey put:anObject
!

bindValue:anObject to:key1 followedBy:key2
    |submap|

    submap := self at:key1.
    submap isNil ifTrue:[
        submap := KeyboardMap new.
        self at:key1 put:submap.
    ].
    submap at:key2 put:anObject
!

valueFor:aKey
    |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
! !