43 The setup of this map is done in the 'smalltalk.rc' or one of the |
43 The setup of this map is done in the 'smalltalk.rc' or one of the |
44 'display.rc' files during startup. |
44 'display.rc' files during startup. |
45 To add a mapping (for example, to attach the logical function 'DoIt' to |
45 To add a mapping (for example, to attach the logical function 'DoIt' to |
46 the key-combination Cmd-'d'): |
46 the key-combination Cmd-'d'): |
47 |
47 |
48 |m| |
48 |m| |
49 |
49 |
50 m := Display keyboardMap. |
50 m := Display keyboardMap. |
51 m bindValue:#DoIt to:#Cmdd. |
51 m bindValue:#DoIt to:#Cmdd. |
52 |
52 |
53 Key sequences can also be defined (hey emacs fans ;-) as in: |
53 Key sequences can also be defined (hey emacs fans ;-) as in: |
54 |
54 |
55 |m| |
55 |m| |
56 |
56 |
57 m := Display keyboardMap. |
57 m := Display keyboardMap. |
58 m bindValue:#DoIt to:#Ctrlx followedBy:#Ctrld |
58 m bindValue:#DoIt to:#Ctrlx followedBy:#Ctrld |
59 |
59 |
60 Key prefixes are defined in the DeviceWorkstation>>translateKey: method. |
60 Key prefixes are defined in the DeviceWorkstation>>translateKey: method. |
61 Typical prefixes are Cmd (for Alt or Meta), Ctrl etc. |
61 Typical prefixes are Cmd (for Alt or Meta), Ctrl etc. |
62 Some keyboards offer both Alt and Meta keys - on those, the first has a |
62 Some keyboards offer both Alt and Meta keys - on those, the first has a |
63 prefix of Alt, the second has Cmd as prefix. Keyboards with only an Alt |
63 prefix of Alt, the second has Cmd as prefix. Keyboards with only an Alt |
64 key will will create prefix codes of Cmd for that. |
64 key will will create prefix codes of Cmd for that. |
65 |
65 |
66 To remove a mapping, use the same value for both logical and physical key, |
66 To remove a mapping, use the same value for both logical and physical key, |
67 as in: |
67 as in: |
68 |
68 |
69 |m| |
69 |m| |
70 |
70 |
71 m := Display keyboardMap. |
71 m := Display keyboardMap. |
72 m bindValue:#Cmdd to:#Cmdd. |
72 m bindValue:#Cmdd to:#Cmdd. |
|
73 |
|
74 [see also:] |
|
75 WindowEvent WindowSensor WindowGroup |
|
76 View DeviceWorkstation |
73 " |
77 " |
74 ! ! |
78 ! ! |
75 |
79 |
76 !KeyboardMap methodsFor:'accessing'! |
80 !KeyboardMap methodsFor:'accessing'! |
77 |
81 |
78 bindValue:logicalKey to:aKey |
82 bindValue:logicalKey to:aKey |
|
83 "bind aLogicalKey to a rawKey. |
|
84 The event mechanism uses this to pass logical keyboard events |
|
85 to the application (such as #Copy, #Cut etc.) |
|
86 instead of physical ones (such as #AltC, #AltX)" |
|
87 |
79 aKey == logicalKey ifTrue:[ |
88 aKey == logicalKey ifTrue:[ |
80 self removeKey:aKey |
89 self removeKey:aKey |
81 ] ifFalse:[ |
90 ] ifFalse:[ |
82 self at:aKey put:logicalKey |
91 self at:aKey put:logicalKey |
83 ] |
92 ] |
|
93 |
|
94 "Modified: 23.4.1996 / 21:54:45 / cg" |
84 ! |
95 ! |
85 |
96 |
86 bindValue:logicalKey to:key1 followedBy:key2 |
97 bindValue:logicalKey to:key1 followedBy:key2 |
|
98 "bind aLogicalKey to a sequence of two rawKeys. |
|
99 The event mechanism uses this to pass logical keyboard events |
|
100 to the application (such as #Copy, #Cut etc.) |
|
101 instead of physical ones (such as #AltC, #AltX)" |
|
102 |
87 |submap| |
103 |submap| |
88 |
104 |
89 submap := self at:key1 ifAbsent:[]. |
105 submap := self at:key1 ifAbsent:[]. |
90 submap isNil ifTrue:[ |
106 submap isNil ifTrue:[ |
91 submap := KeyboardMap new. |
107 submap := KeyboardMap new. |
92 self at:key1 put:submap. |
108 self at:key1 put:submap. |
93 ]. |
109 ]. |
94 submap at:key2 put:logicalKey |
110 submap at:key2 put:logicalKey |
|
111 |
|
112 "Modified: 23.4.1996 / 21:55:04 / cg" |
95 ! |
113 ! |
96 |
114 |
97 valueFor:aKey |
115 valueFor:aKey |
|
116 "retrieve a logical key" |
|
117 |
98 |where value| |
118 |where value| |
99 |
119 |
100 where := (current notNil ifTrue:[current] ifFalse:[self]). |
120 where := (current notNil ifTrue:[current] ifFalse:[self]). |
101 |
121 |
102 value := where at:aKey ifAbsent:aKey. |
122 value := where at:aKey ifAbsent:aKey. |
103 (value isMemberOf:KeyboardMap) ifTrue:[ |
123 (value isMemberOf:KeyboardMap) ifTrue:[ |
104 current := value. |
124 current := value. |
105 ^ nil. |
125 ^ nil. |
106 ]. |
126 ]. |
107 current := nil. |
127 current := nil. |
108 ^ value |
128 ^ value |
|
129 |
|
130 "Modified: 23.4.1996 / 21:55:22 / cg" |
109 ! ! |
131 ! ! |
110 |
132 |
111 !KeyboardMap class methodsFor:'documentation'! |
133 !KeyboardMap class methodsFor:'documentation'! |
112 |
134 |
113 version |
135 version |
114 ^ '$Header: /cvs/stx/stx/libview/Attic/KeybdMap.st,v 1.9 1995-11-23 17:45:09 cg Exp $' |
136 ^ '$Header: /cvs/stx/stx/libview/Attic/KeybdMap.st,v 1.10 1996-04-23 19:56:52 cg Exp $' |
115 ! ! |
137 ! ! |