KeyboardMap.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 08 Feb 2017 23:58:18 +0000
branchjv
changeset 7969 2bac4f32553f
parent 7856 7c52e7a9a087
child 8035 8bbd397fe321
permissions -rw-r--r--
Allow individual applications to define their own shortcut mapping When a system wants to translate a shortcut into a logical action key, it asks a view to it's keyboard map which porivdes such translations. Histrically, there was only one such map kept in window device. To allow per-application customization, each view by default returns its parent's view map. The top level window then asks its underlaying application model for a map. This way, each application may provide its own shortcut mappings or override / inhibit global ones. Keyboard mappings may be chained to from a hiearchy: if a mapping is not found in given keyboard map, it's parent map (if any) is asked for the mapping. Usually a device's keyboard map is at the top of the hiearchy (but not necessarily)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     1
"
48194c26a46c Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
     3
	      All Rights Reserved
0
48194c26a46c Initial revision
claus
parents:
diff changeset
     4
48194c26a46c Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
48194c26a46c Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
48194c26a46c Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
48194c26a46c Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
48194c26a46c Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
48194c26a46c Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
48194c26a46c Initial revision
claus
parents:
diff changeset
    11
"
5280
77ce8475efed category change
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
    12
"{ Package: 'stx:libview' }"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    13
7856
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    14
"{ NameSpace: Smalltalk }"
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    15
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    16
IdentityDictionary subclass:#KeyboardMap
7856
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    17
	instanceVariableNames:'parent current'
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    18
	classVariableNames:''
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    19
	poolDictionaries:''
5280
77ce8475efed category change
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
    20
	category:'Interface-Support-UI'
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    21
!
48194c26a46c Initial revision
claus
parents:
diff changeset
    22
46
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    23
!KeyboardMap class methodsFor:'documentation'!
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    24
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    25
copyright
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    26
"
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    27
 COPYRIGHT (c) 1993 by Claus Gittinger
72
3e84121988c3 *** empty log message ***
claus
parents: 54
diff changeset
    28
	      All Rights Reserved
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    29
46
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    30
 This software is furnished under a license and may be used
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    31
 only in accordance with the terms of that license and with the
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    33
 be provided or otherwise made available to, or used by, any
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    34
 other person.  No title to or ownership of the software is
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    35
 hereby transferred.
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    36
"
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    37
!
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    38
46
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    39
documentation
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    40
"
7856
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    41
    Instances of KeyboardMap are used for mapping keystrokes AND sequences
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    42
    of keystrokes to a logical function which is used by UI code. For
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    43
    example, it maps #Ctrls to #Accept logical function which is then
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    44
    used menu items and so on.
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    45
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    46
    This allows for changing a shortcut without changing the code.
89
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    47
7856
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    48
    Keyboard maps may chained together, if a mapping is not found in
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    49
    a particular key map, lookup continues in its parent map (if any).
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    50
    Usually the grand-parent is device's standard map, see
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    51
    DeviceWorkstation >> keyboardMap (but not necessarily!!)
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    52
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    53
    The setup of device's map is done in the 'smalltalk.rc' or one of the
6663
a3d11f506f57 class: KeyboardMap
Claus Gittinger <cg@exept.de>
parents: 6556
diff changeset
    54
    'keyboard.rc' files during startup.
7856
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
    55
89
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    56
    To add a mapping (for example, to attach the logical function 'DoIt' to
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    57
    the key-combination Cmd-'d'):
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    58
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    59
        |m|
89
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    60
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    61
        m := Display keyboardMap.
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    62
        m bindValue:#DoIt to:#Cmdd.
89
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    63
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    64
    Key sequences can also be defined (hey emacs fans ;-) as in:
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    65
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    66
        |m|
89
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    67
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    68
        m := Display keyboardMap.
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    69
        m bindValue:#DoIt to:#Ctrlx followedBy:#Ctrld
89
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    70
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    71
    Key prefixes are defined in the DeviceWorkstation>>translateKey: method.
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    72
    Typical prefixes are Cmd (for Alt or Meta), Ctrl etc.
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    73
    Some keyboards offer both Alt and Meta keys - on those, the first has a
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    74
    prefix of Alt, the second has Cmd as prefix. Keyboards with only an Alt
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    75
    key will will create prefix codes of Cmd for that.
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    76
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    77
    To remove a mapping, use the same value for both logical and physical key,
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    78
    as in:
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    79
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    80
        |m|
89
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    81
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    82
        m := Display keyboardMap.
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    83
        m bindValue:#Cmdd to:#Cmdd.
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    84
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    85
    [see also:]
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    86
        WindowEvent WindowSensor WindowGroup
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    87
        View DeviceWorkstation
612
8758d0c9933e documentation
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
    88
8758d0c9933e documentation
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
    89
    [author:]
8758d0c9933e documentation
Claus Gittinger <cg@exept.de>
parents: 598
diff changeset
    90
        Claus Gittinger
46
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    91
"
7b331e9012fd *** empty log message ***
claus
parents: 5
diff changeset
    92
! !
0
48194c26a46c Initial revision
claus
parents:
diff changeset
    93
48194c26a46c Initial revision
claus
parents:
diff changeset
    94
!KeyboardMap methodsFor:'accessing'!
48194c26a46c Initial revision
claus
parents:
diff changeset
    95
89
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
    96
bindValue:logicalKey to:aKey
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    97
    "bind aLogicalKey to a rawKey.
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    98
     The event mechanism uses this to pass logical keyboard events
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
    99
     to the application (such as #Copy, #Cut etc.) 
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   100
     instead of physical ones (such as #AltC, #AltX)"
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   101
89
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
   102
    aKey == logicalKey ifTrue:[
1120
616388474f7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   103
        self removeKey:aKey ifAbsent:nil
89
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
   104
    ] ifFalse:[
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   105
        self at:aKey put:logicalKey
89
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
   106
    ]
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   107
1120
616388474f7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 612
diff changeset
   108
    "Modified: 12.11.1996 / 10:30:56 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   109
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   110
89
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
   111
bindValue:logicalKey to:key1 followedBy:key2
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   112
    "bind aLogicalKey to a sequence of two rawKeys.
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   113
     The event mechanism uses this to pass logical keyboard events
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   114
     to the application (such as #Copy, #Cut etc.) 
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   115
     instead of physical ones (such as #AltC, #AltX)"
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   116
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   117
    |submap|
48194c26a46c Initial revision
claus
parents:
diff changeset
   118
89
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
   119
    submap := self at:key1 ifAbsent:[].
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   120
    submap isNil ifTrue:[
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   121
        submap := KeyboardMap new.
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   122
        self at:key1 put:submap.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   123
    ].
89
ea2bf46eb669 *** empty log message ***
claus
parents: 72
diff changeset
   124
    submap at:key2 put:logicalKey
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   125
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   126
    "Modified: 23.4.1996 / 21:55:04 / cg"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   127
!
48194c26a46c Initial revision
claus
parents:
diff changeset
   128
6556
f2418ba5d1c5 class: KeyboardMap
Claus Gittinger <cg@exept.de>
parents: 5280
diff changeset
   129
hasBindingFor:aKey
f2418ba5d1c5 class: KeyboardMap
Claus Gittinger <cg@exept.de>
parents: 5280
diff changeset
   130
    "retrieve a logical key"
f2418ba5d1c5 class: KeyboardMap
Claus Gittinger <cg@exept.de>
parents: 5280
diff changeset
   131
7856
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   132
    current notNil ifTrue:[
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   133
        ^ current includesKey:aKey
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   134
    ].
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   135
    (self includesKey:aKey) ifTrue:[ ^ true ].
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   136
    parent notNil ifTrue:[ 
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   137
        parent hasBindingFor:aKey
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   138
    ].
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   139
    ^ false
6556
f2418ba5d1c5 class: KeyboardMap
Claus Gittinger <cg@exept.de>
parents: 5280
diff changeset
   140
7856
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   141
    "Modified: / 02-02-2017 / 00:13:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   142
!
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   143
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   144
parent
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   145
    ^ parent
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   146
!
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   147
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   148
parent:aKeyboardMap
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   149
    parent := aKeyboardMap.
6556
f2418ba5d1c5 class: KeyboardMap
Claus Gittinger <cg@exept.de>
parents: 5280
diff changeset
   150
!
f2418ba5d1c5 class: KeyboardMap
Claus Gittinger <cg@exept.de>
parents: 5280
diff changeset
   151
7969
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   152
rawKeysForLogical: logicalKey
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   153
    "Return all raw keys for given )possibly) logical key.
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   154
     Example:
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   155
       #Copy -> #(Ctrlc) - depending on mappings
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   156
    "
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   157
    | map rawKeys |
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   158
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   159
    map := self.
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   160
    rawKeys := #().
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   161
    [ rawKeys isEmpty and:[ map notNil ] ] whileTrue:[
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   162
        map keysAndValuesDo:[ :raw :logical | logical == logicalKey ifTrue:[ rawKeys := rawKeys copyWith: raw ] ].
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   163
        map := map parent.
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   164
    ].
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   165
    ^ rawKeys
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   166
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   167
    "
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   168
    Screen current keyboardMap rawKeysForLogical: #Copy
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   169
    "
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   170
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   171
    "Created: / 08-02-2017 / 23:43:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   172
!
2bac4f32553f Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 7856
diff changeset
   173
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   174
valueFor:aKey
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   175
    "retrieve a logical key"
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   176
6556
f2418ba5d1c5 class: KeyboardMap
Claus Gittinger <cg@exept.de>
parents: 5280
diff changeset
   177
    |whichMap value|
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   178
6556
f2418ba5d1c5 class: KeyboardMap
Claus Gittinger <cg@exept.de>
parents: 5280
diff changeset
   179
    whichMap := (current notNil ifTrue:[current] ifFalse:[self]).
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   180
7856
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   181
    value := whichMap at:aKey ifAbsent:[ nil ].
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   182
    (value isMemberOf:KeyboardMap) ifTrue:[
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   183
        current := value.
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   184
        ^ nil.
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   185
    ].
48194c26a46c Initial revision
claus
parents:
diff changeset
   186
    current := nil.
7856
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   187
    value isNil ifTrue:[ 
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   188
        parent notNil ifTrue:[
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   189
            ^ parent valueFor: aKey
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   190
        ].
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   191
        "/ No mapping for given key, return it unmapped
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   192
        ^ aKey
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   193
    ].
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   194
    ^ value
598
1a2339e902d4 commentary
Claus Gittinger <cg@exept.de>
parents: 251
diff changeset
   195
7856
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   196
    "Modified: / 23-04-1996 / 21:55:22 / cg"
7c52e7a9a087 Allow individual applications to define their own shortcut mapping
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6663
diff changeset
   197
    "Modified: / 04-02-2017 / 22:24:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0
48194c26a46c Initial revision
claus
parents:
diff changeset
   198
! !
244
83218faf792c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   199
251
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   200
!KeyboardMap class methodsFor:'documentation'!
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   201
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   202
version
6663
a3d11f506f57 class: KeyboardMap
Claus Gittinger <cg@exept.de>
parents: 6556
diff changeset
   203
    ^ '$Header: /cvs/stx/stx/libview/KeyboardMap.st,v 1.15 2014-12-18 16:13:06 cg Exp $'
251
915de9a65169 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 244
diff changeset
   204
! !
6556
f2418ba5d1c5 class: KeyboardMap
Claus Gittinger <cg@exept.de>
parents: 5280
diff changeset
   205