0
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
72
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
5280
|
12 |
"{ Package: 'stx:libview' }"
|
0
|
13 |
|
244
|
14 |
IdentityDictionary subclass:#KeyboardMap
|
598
|
15 |
instanceVariableNames:'current'
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
5280
|
18 |
category:'Interface-Support-UI'
|
0
|
19 |
!
|
|
20 |
|
46
|
21 |
!KeyboardMap class methodsFor:'documentation'!
|
|
22 |
|
|
23 |
copyright
|
|
24 |
"
|
|
25 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
72
|
26 |
All Rights Reserved
|
0
|
27 |
|
46
|
28 |
This software is furnished under a license and may be used
|
|
29 |
only in accordance with the terms of that license and with the
|
|
30 |
inclusion of the above copyright notice. This software may not
|
|
31 |
be provided or otherwise made available to, or used by, any
|
|
32 |
other person. No title to or ownership of the software is
|
|
33 |
hereby transferred.
|
|
34 |
"
|
|
35 |
!
|
0
|
36 |
|
46
|
37 |
documentation
|
|
38 |
"
|
|
39 |
instances of KeyboardMap are used for mapping keystrokes AND sequences
|
|
40 |
of keystrokes to a function key.
|
89
|
41 |
There is usually only one instance in the system - held in an instance
|
|
42 |
variable of Display.
|
|
43 |
|
|
44 |
The setup of this map is done in the 'smalltalk.rc' or one of the
|
6663
|
45 |
'keyboard.rc' files during startup.
|
89
|
46 |
To add a mapping (for example, to attach the logical function 'DoIt' to
|
|
47 |
the key-combination Cmd-'d'):
|
|
48 |
|
598
|
49 |
|m|
|
89
|
50 |
|
598
|
51 |
m := Display keyboardMap.
|
|
52 |
m bindValue:#DoIt to:#Cmdd.
|
89
|
53 |
|
|
54 |
Key sequences can also be defined (hey emacs fans ;-) as in:
|
|
55 |
|
598
|
56 |
|m|
|
89
|
57 |
|
598
|
58 |
m := Display keyboardMap.
|
|
59 |
m bindValue:#DoIt to:#Ctrlx followedBy:#Ctrld
|
89
|
60 |
|
|
61 |
Key prefixes are defined in the DeviceWorkstation>>translateKey: method.
|
|
62 |
Typical prefixes are Cmd (for Alt or Meta), Ctrl etc.
|
|
63 |
Some keyboards offer both Alt and Meta keys - on those, the first has a
|
|
64 |
prefix of Alt, the second has Cmd as prefix. Keyboards with only an Alt
|
|
65 |
key will will create prefix codes of Cmd for that.
|
|
66 |
|
|
67 |
To remove a mapping, use the same value for both logical and physical key,
|
|
68 |
as in:
|
|
69 |
|
598
|
70 |
|m|
|
89
|
71 |
|
598
|
72 |
m := Display keyboardMap.
|
|
73 |
m bindValue:#Cmdd to:#Cmdd.
|
|
74 |
|
|
75 |
[see also:]
|
|
76 |
WindowEvent WindowSensor WindowGroup
|
|
77 |
View DeviceWorkstation
|
612
|
78 |
|
|
79 |
[author:]
|
|
80 |
Claus Gittinger
|
46
|
81 |
"
|
|
82 |
! !
|
0
|
83 |
|
|
84 |
!KeyboardMap methodsFor:'accessing'!
|
|
85 |
|
89
|
86 |
bindValue:logicalKey to:aKey
|
598
|
87 |
"bind aLogicalKey to a rawKey.
|
|
88 |
The event mechanism uses this to pass logical keyboard events
|
|
89 |
to the application (such as #Copy, #Cut etc.)
|
|
90 |
instead of physical ones (such as #AltC, #AltX)"
|
|
91 |
|
89
|
92 |
aKey == logicalKey ifTrue:[
|
1120
|
93 |
self removeKey:aKey ifAbsent:nil
|
89
|
94 |
] ifFalse:[
|
598
|
95 |
self at:aKey put:logicalKey
|
89
|
96 |
]
|
598
|
97 |
|
1120
|
98 |
"Modified: 12.11.1996 / 10:30:56 / cg"
|
0
|
99 |
!
|
|
100 |
|
89
|
101 |
bindValue:logicalKey to:key1 followedBy:key2
|
598
|
102 |
"bind aLogicalKey to a sequence of two rawKeys.
|
|
103 |
The event mechanism uses this to pass logical keyboard events
|
|
104 |
to the application (such as #Copy, #Cut etc.)
|
|
105 |
instead of physical ones (such as #AltC, #AltX)"
|
|
106 |
|
0
|
107 |
|submap|
|
|
108 |
|
89
|
109 |
submap := self at:key1 ifAbsent:[].
|
0
|
110 |
submap isNil ifTrue:[
|
598
|
111 |
submap := KeyboardMap new.
|
|
112 |
self at:key1 put:submap.
|
0
|
113 |
].
|
89
|
114 |
submap at:key2 put:logicalKey
|
598
|
115 |
|
|
116 |
"Modified: 23.4.1996 / 21:55:04 / cg"
|
0
|
117 |
!
|
|
118 |
|
6556
|
119 |
hasBindingFor:aKey
|
|
120 |
"retrieve a logical key"
|
|
121 |
|
|
122 |
|whichMap|
|
|
123 |
|
|
124 |
whichMap := (current notNil ifTrue:[current] ifFalse:[self]).
|
|
125 |
^ whichMap includesKey:aKey
|
|
126 |
!
|
|
127 |
|
0
|
128 |
valueFor:aKey
|
598
|
129 |
"retrieve a logical key"
|
|
130 |
|
6556
|
131 |
|whichMap value|
|
0
|
132 |
|
6556
|
133 |
whichMap := (current notNil ifTrue:[current] ifFalse:[self]).
|
0
|
134 |
|
6556
|
135 |
value := whichMap at:aKey ifAbsent:aKey.
|
0
|
136 |
(value isMemberOf:KeyboardMap) ifTrue:[
|
598
|
137 |
current := value.
|
|
138 |
^ nil.
|
0
|
139 |
].
|
|
140 |
current := nil.
|
|
141 |
^ value
|
598
|
142 |
|
|
143 |
"Modified: 23.4.1996 / 21:55:22 / cg"
|
0
|
144 |
! !
|
244
|
145 |
|
251
|
146 |
!KeyboardMap class methodsFor:'documentation'!
|
|
147 |
|
|
148 |
version
|
6663
|
149 |
^ '$Header: /cvs/stx/stx/libview/KeyboardMap.st,v 1.15 2014-12-18 16:13:06 cg Exp $'
|
251
|
150 |
! !
|
6556
|
151 |
|