author | Claus Gittinger <cg@exept.de> |
Thu, 08 May 2008 11:18:43 +0200 | |
changeset 2447 | ecb0212e1c8d |
parent 2443 | 1043b37a4a5a |
child 2488 | ed0fabedfe4e |
permissions | -rw-r--r-- |
1124 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
" |
|
1388 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
1124 | 14 |
Object subclass:#KeyboardProcessor |
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
15 |
instanceVariableNames:'returnIsOKInDialog escapeIsCancelInDialog menuBar |
2443
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
16 |
autoAcceptListeners globalAccelerators componentWithInitialFocus |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
17 |
altFunctionWasExecuted' |
1124 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
2360 | 20 |
category:'Interface-Framework' |
1124 | 21 |
! |
22 |
||
23 |
!KeyboardProcessor class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
||
38 |
||
39 |
||
40 |
||
41 |
! |
|
42 |
||
43 |
documentation |
|
44 |
" |
|
45 |
ST80 compatibility (mimicry) class. |
|
46 |
||
47 |
The class is not completed yet and certainly not bug free. |
|
48 |
||
49 |
Notice: |
|
50 |
this class was implemented using protocol information |
|
51 |
from alpha testers, literature and by reading public domain code |
|
52 |
- it may not be complete or compatible to |
|
53 |
the corresponding ST-80 class. |
|
54 |
If you encounter any incompatibilities, please forward a note |
|
55 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
56 |
||
1160 | 57 |
KeyboardProcessor is going to take over the focus control |
58 |
mechanism (which are currently located in the windowGroup). |
|
59 |
Currently, it keeps track of inputFields, and allows for |
|
60 |
a global accept to be forced. |
|
61 |
This is especially useful with dialogs, where a global accept |
|
62 |
should be performed on all inputFields, when the OK button |
|
63 |
is pressed. |
|
64 |
||
1124 | 65 |
[author:] |
1160 | 66 |
Claus Gittinger |
1124 | 67 |
" |
68 |
||
69 |
||
70 |
||
71 |
||
72 |
! ! |
|
73 |
||
1422 | 74 |
!KeyboardProcessor class methodsFor:'defaults'! |
75 |
||
1455
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
76 |
isKeyEventIgnoredAsShortcut:aKeyEvent |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
77 |
"returns true if the key event ignored is a shortCut key |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
78 |
" |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
79 |
|rawKey| |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
80 |
|
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
81 |
rawKey := aKeyEvent rawKey. |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
82 |
rawKey isSymbol ifFalse:[^ true]. |
1503
b3c4b1b1bfbb
cursor keys ARE allowed as accelerators (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
83 |
"/ "/ ignore cursor keys |
b3c4b1b1bfbb
cursor keys ARE allowed as accelerators (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
84 |
"/ (#( |
b3c4b1b1bfbb
cursor keys ARE allowed as accelerators (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
85 |
"/ Up Down Left Right |
b3c4b1b1bfbb
cursor keys ARE allowed as accelerators (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
86 |
"/ CursorUp CursorDown CursorLeft CursorRight |
b3c4b1b1bfbb
cursor keys ARE allowed as accelerators (is this a good idea ?)
Claus Gittinger <cg@exept.de>
parents:
1499
diff
changeset
|
87 |
"/ ) includes:rawKey) ifTrue:[^ true]. |
1455
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
88 |
|
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
89 |
"/ ignore some meta keys |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
90 |
(#( |
1499 | 91 |
#'Control_L' #'Control_R' #'Control' #'Ctrl' |
92 |
#'CmdMenu' #'BackSpace' #Tab |
|
2443
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
93 |
#'Cmd_L' #'Cmd_R' #'Cmd' #'Menu' |
1499 | 94 |
#'Shift_L' #'Shift_R' Shift |
95 |
#'Alt_L' #'Alt_R' #'Alt' |
|
96 |
#'Super_R' #'Super_L' #'Super' |
|
1455
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
97 |
) includes:aKeyEvent key) ifTrue:[^ true]. |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
98 |
|
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
99 |
^ false |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
100 |
|
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
101 |
"Created: / 17.1.2001 / 11:57:07 / cg" |
1457 | 102 |
"Modified: / 17.1.2001 / 13:05:46 / cg" |
1455
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
103 |
! |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
104 |
|
1422 | 105 |
isMnemonicKeyEvent:aKeyEvent |
2386 | 106 |
"returns true if the key event is a mnemonic key (such as Cmda) |
1422 | 107 |
" |
108 |
|rawKey| |
|
109 |
||
110 |
rawKey := aKeyEvent rawKey. |
|
2397 | 111 |
^ rawKey size == 4 "/ only CMD-single letter !! |
112 |
and:[rawKey startsWith:'Cmd'] "/ CmdMenu for right-alt in vmware ??? |
|
1443 | 113 |
! ! |
1422 | 114 |
|
1763 | 115 |
!KeyboardProcessor methodsFor:'Compatibility-VW'! |
1124 | 116 |
|
117 |
keyboardConsumers |
|
118 |
^ #() |
|
119 |
||
120 |
"Created: 6.3.1997 / 15:16:32 / cg" |
|
121 |
! |
|
122 |
||
123 |
removeKeyboardReceiver:aController |
|
124 |
||
125 |
"Created: / 31.10.1997 / 01:56:54 / cg" |
|
126 |
! |
|
127 |
||
128 |
sendKeyboardTo:aController |
|
129 |
||
130 |
"Created: / 31.10.1997 / 01:57:15 / cg" |
|
131 |
! |
|
132 |
||
133 |
setActive:aWidget |
|
134 |
||
135 |
"Created: 3.3.1997 / 18:31:09 / cg" |
|
136 |
! ! |
|
137 |
||
138 |
!KeyboardProcessor methodsFor:'accessing'! |
|
139 |
||
1251 | 140 |
addAccelerator:aKey action:aSelectorOrBlock |
141 |
"add a global accelerator - these are handled even if no corresponding |
|
142 |
menu shortcut is defined" |
|
143 |
||
144 |
globalAccelerators isNil ifTrue:[ |
|
145 |
globalAccelerators := Dictionary new |
|
146 |
]. |
|
147 |
globalAccelerators at:aKey put:aSelectorOrBlock |
|
148 |
! |
|
149 |
||
1983 | 150 |
componentWithInitialFocus |
151 |
^ componentWithInitialFocus |
|
152 |
! |
|
153 |
||
154 |
componentWithInitialFocus:aComponent |
|
155 |
componentWithInitialFocus := aComponent |
|
156 |
! |
|
157 |
||
1124 | 158 |
escapeIsCancelInDialog:aBoolean |
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
159 |
"set the escapeIsCancel flag. |
1635 | 160 |
If off, Escape is NOT handled as cancel (the builder defaults it to true,)" |
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
161 |
|
1124 | 162 |
escapeIsCancelInDialog := aBoolean |
163 |
! |
|
164 |
||
165 |
menuBar |
|
166 |
"return the value of the instance variable 'menuBar' (automatically generated)" |
|
167 |
||
1443 | 168 |
^ menuBar |
169 |
! |
|
1124 | 170 |
|
171 |
menuBar:something |
|
172 |
"set the value of the instance variable 'menuBar' (automatically generated)" |
|
173 |
||
1443 | 174 |
menuBar := something. |
175 |
! |
|
1124 | 176 |
|
177 |
returnIsOKInDialog:aBoolean |
|
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
178 |
"set the returnIsOK flag. |
1635 | 179 |
If off, Return is NOT handled as accept (the builder defaults it to true,)" |
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
180 |
|
1124 | 181 |
returnIsOKInDialog := aBoolean |
182 |
! ! |
|
183 |
||
184 |
!KeyboardProcessor methodsFor:'event handling'! |
|
185 |
||
1135 | 186 |
processEvent:event forModalView:modalTopOrNil |
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
187 |
"process a key-event; return true, if handled & eaten; false if not. |
1251 | 188 |
Here, first, we look for a globalAccelerator, |
189 |
then for Return and Escape in modal applications, |
|
190 |
(which lead to Accept & Cancel resp.) |
|
191 |
Finally, menu-shortcuts are handled." |
|
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
192 |
|
2007
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
193 |
|key rawKey topView wg app view action explicitFocusView focusView| |
1124 | 194 |
|
2443
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
195 |
event isKeyEvent ifFalse:[ ^ false ]. |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
196 |
|
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
197 |
key := event key. |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
198 |
rawKey := event rawKey. |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
199 |
|
1124 | 200 |
view := event view. |
201 |
||
2443
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
202 |
topView := modalTopOrNil ? view topView. |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
203 |
wg := topView windowGroup. |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
204 |
app := topView application. |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
205 |
|
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
206 |
"/ little state machine, to detect if the alt-key was pressed |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
207 |
"/ without a concrete command key. |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
208 |
"/ this will bring the focus to the menuPanel, if there is one. |
2447
ecb0212e1c8d
ALT-key processing disabled (temporarily)
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
209 |
"/ cg: disabled for now; |
ecb0212e1c8d
ALT-key processing disabled (temporarily)
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
210 |
"/ leads to occasional leftover popupmenus floating around; |
ecb0212e1c8d
ALT-key processing disabled (temporarily)
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
211 |
"/ ca has to look for this first. |
ecb0212e1c8d
ALT-key processing disabled (temporarily)
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
212 |
false ifTrue:[ |
2443
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
213 |
key = #'Cmd' ifTrue:[ |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
214 |
event isKeyPressEvent ifTrue:[ |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
215 |
altFunctionWasExecuted := false. |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
216 |
] ifFalse:[ |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
217 |
event isKeyReleaseEvent ifTrue:[ |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
218 |
altFunctionWasExecuted ifFalse:[ |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
219 |
(wg processShortcut:event) ifTrue:[ |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
220 |
^ true |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
221 |
]. |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
222 |
]. |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
223 |
]. |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
224 |
]. |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
225 |
] ifFalse:[ |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
226 |
altFunctionWasExecuted := true. |
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
227 |
]. |
2447
ecb0212e1c8d
ALT-key processing disabled (temporarily)
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
228 |
]. |
2443
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
229 |
|
1124 | 230 |
event isKeyPressEvent ifTrue:[ |
2443
1043b37a4a5a
Alt-key alone catches focus and selects first item
Claus Gittinger <cg@exept.de>
parents:
2400
diff
changeset
|
231 |
"/ key startsWith:'Cmd' |
1124 | 232 |
|
1251 | 233 |
"/ how about global accelerators ? |
234 |
(globalAccelerators notNil |
|
235 |
and:[(action := globalAccelerators at:key ifAbsent:nil) notNil]) |
|
236 |
ifTrue:[ |
|
1492 | 237 |
event consumed:true. |
1251 | 238 |
action isSymbol ifTrue:[ |
1422 | 239 |
app notNil ifTrue:[ |
240 |
action numArgs == 1 ifTrue:[ |
|
241 |
app perform:action with:event |
|
242 |
] ifFalse:[ |
|
243 |
app perform:action |
|
244 |
]. |
|
245 |
] |
|
1251 | 246 |
] ifFalse:[ |
247 |
action numArgs == 1 ifTrue:[ |
|
248 |
action value:event |
|
249 |
] ifFalse:[ |
|
250 |
action value |
|
251 |
] |
|
252 |
]. |
|
1492 | 253 |
"/ ^ true |
254 |
^ event consumed |
|
1251 | 255 |
]. |
1488
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
256 |
|
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
257 |
topView isModal ifTrue:[ |
1637 | 258 |
(key == #Return and:[returnIsOKInDialog ? true]) ifTrue:[ |
259 |
(wg notNil |
|
2007
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
260 |
and:[(explicitFocusView := wg explicitFocusView) isNil |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
261 |
or:[ explicitFocusView isKeyboardConsumer not |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
262 |
or:[ explicitFocusView isInputField ] ] |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
263 |
]) ifTrue:[ |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
264 |
((focusView := wg focusView) notNil and:[focusView isTextView]) ifTrue:[ |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
265 |
focusView isInputField ifFalse:[ |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
266 |
"/ modalBox with a TextView |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
267 |
^ false |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
268 |
]. |
2008
bc367a4d7d6a
kludge for subcanvas-inputfields
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
269 |
"/ this is a kludge for subcanvas' input-fields, which |
bc367a4d7d6a
kludge for subcanvas-inputfields
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
270 |
"/ are not affected by #requestGlobalAutoAccept below. |
2007
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
271 |
focusView isAcceptOnReturn ifTrue:[ |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
272 |
focusView accept |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
273 |
]. |
2006
83d2e7259fcf
ignore return (do not close) if the current
Claus Gittinger <cg@exept.de>
parents:
1983
diff
changeset
|
274 |
]. |
83d2e7259fcf
ignore return (do not close) if the current
Claus Gittinger <cg@exept.de>
parents:
1983
diff
changeset
|
275 |
|
1488
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
276 |
self requestGlobalAutoAccept ifFalse:[^ true]. |
1636
c9ed206b5d32
escapeIsCancel/returnIsOK in popup with same app as mainapp
ca
parents:
1635
diff
changeset
|
277 |
|
c9ed206b5d32
escapeIsCancel/returnIsOK in popup with same app as mainapp
ca
parents:
1635
diff
changeset
|
278 |
"/ only care for RETURN and ESC if the window is the |
c9ed206b5d32
escapeIsCancel/returnIsOK in popup with same app as mainapp
ca
parents:
1635
diff
changeset
|
279 |
"/ apps topView (not if its a popup or dialog of it) |
c9ed206b5d32
escapeIsCancel/returnIsOK in popup with same app as mainapp
ca
parents:
1635
diff
changeset
|
280 |
(app notNil and:[app window == topView]) ifTrue:[ |
1794
81e71050bce2
extra hooks for ok/cancel via keyboard
Claus Gittinger <cg@exept.de>
parents:
1763
diff
changeset
|
281 |
app doAcceptByReturnKey. |
1488
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
282 |
] ifFalse:[ |
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
283 |
"/ oldStyle modalBox - for now, let Box handle it itself |
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
284 |
^ false |
1422 | 285 |
]. |
1134
758151d73aac
only do autoAccept, if there is no focus view.
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
286 |
^ true |
758151d73aac
only do autoAccept, if there is no focus view.
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
287 |
]. |
1124 | 288 |
]. |
1637 | 289 |
(key == #Escape and:[escapeIsCancelInDialog ? true]) ifTrue:[ |
1636
c9ed206b5d32
escapeIsCancel/returnIsOK in popup with same app as mainapp
ca
parents:
1635
diff
changeset
|
290 |
"/ only care for RETURN and ESC if the window is the |
c9ed206b5d32
escapeIsCancel/returnIsOK in popup with same app as mainapp
ca
parents:
1635
diff
changeset
|
291 |
"/ apps topView (not if its a popup or dialog of it) |
c9ed206b5d32
escapeIsCancel/returnIsOK in popup with same app as mainapp
ca
parents:
1635
diff
changeset
|
292 |
(app notNil and:[app window == topView]) ifTrue:[ |
1794
81e71050bce2
extra hooks for ok/cancel via keyboard
Claus Gittinger <cg@exept.de>
parents:
1763
diff
changeset
|
293 |
app doCancelByEscapeKey. |
1488
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
294 |
] ifFalse:[ |
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
295 |
"/ oldStyle modalBox - for now, let Box handle it itself |
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
296 |
^ false |
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
297 |
]. |
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
298 |
^ true |
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
299 |
]. |
1422 | 300 |
]. |
1488
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
301 |
|
1455
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
302 |
wg notNil ifTrue:[ |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
303 |
(self class isMnemonicKeyEvent:event) ifTrue:[ |
1456 | 304 |
"/Transcript showCR:event rawKey. |
305 |
"/Transcript showCR:event key. |
|
1455
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
306 |
(wg processMnemonic:event) ifTrue:[ |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
307 |
^ true |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
308 |
] |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
309 |
]. |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
310 |
(self class isKeyEventIgnoredAsShortcut:event) ifFalse:[ |
1456 | 311 |
"/Transcript showCR:event rawKey. |
312 |
"/Transcript showCR:event key. |
|
1455
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
313 |
(wg processShortcut:event) ifTrue:[ |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
314 |
^ true |
1445
50bf6580e064
care for topViews without windowGroup (which should not happen - but...)
tm
parents:
1443
diff
changeset
|
315 |
]. |
1124 | 316 |
]. |
2400
b47e642dd9bc
support ALT-F4 (close window)
Claus Gittinger <cg@exept.de>
parents:
2398
diff
changeset
|
317 |
]. |
b47e642dd9bc
support ALT-F4 (close window)
Claus Gittinger <cg@exept.de>
parents:
2398
diff
changeset
|
318 |
"/ support ALT-F4 (close window) |
b47e642dd9bc
support ALT-F4 (close window)
Claus Gittinger <cg@exept.de>
parents:
2398
diff
changeset
|
319 |
(key == #CloseWindowRequest) ifTrue:[ |
b47e642dd9bc
support ALT-F4 (close window)
Claus Gittinger <cg@exept.de>
parents:
2398
diff
changeset
|
320 |
app notNil ifTrue:[ |
b47e642dd9bc
support ALT-F4 (close window)
Claus Gittinger <cg@exept.de>
parents:
2398
diff
changeset
|
321 |
app closeRequest |
b47e642dd9bc
support ALT-F4 (close window)
Claus Gittinger <cg@exept.de>
parents:
2398
diff
changeset
|
322 |
] ifFalse:[ |
b47e642dd9bc
support ALT-F4 (close window)
Claus Gittinger <cg@exept.de>
parents:
2398
diff
changeset
|
323 |
topView closeRequest |
b47e642dd9bc
support ALT-F4 (close window)
Claus Gittinger <cg@exept.de>
parents:
2398
diff
changeset
|
324 |
]. |
b47e642dd9bc
support ALT-F4 (close window)
Claus Gittinger <cg@exept.de>
parents:
2398
diff
changeset
|
325 |
]. |
1124 | 326 |
]. |
327 |
||
1423 | 328 |
"/ let view dispatch it. |
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
329 |
^ false |
1455
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
330 |
|
1552 | 331 |
"Modified: / 23.12.2001 / 13:12:55 / cg" |
1423 | 332 |
! |
1124 | 333 |
|
334 |
requestForWindowClose |
|
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
335 |
"about to close the window." |
1124 | 336 |
|
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
337 |
^ true |
1124 | 338 |
! |
339 |
||
340 |
requestGlobalAutoAccept |
|
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
341 |
"about to close the window via return ok accept. |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
342 |
Ask all acceptListeners to accept their value and return true, if all of those fields |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
343 |
did." |
1124 | 344 |
|
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
345 |
autoAcceptListeners notNil ifTrue:[ |
2249
150a384a74a6
code cleanup: use #contains/#conform instead of explicit loop
Claus Gittinger <cg@exept.de>
parents:
2008
diff
changeset
|
346 |
^ autoAcceptListeners conform:[:aListener | (aListener requestAutoAccept)] |
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
347 |
]. |
1458
43c22152a2f5
accept autoAccept (RETURN) if no input field widget is present
Claus Gittinger <cg@exept.de>
parents:
1457
diff
changeset
|
348 |
"/ if no input field (or comparable widget) is present ... |
43c22152a2f5
accept autoAccept (RETURN) if no input field widget is present
Claus Gittinger <cg@exept.de>
parents:
1457
diff
changeset
|
349 |
"/ ^ false <- wrong. |
43c22152a2f5
accept autoAccept (RETURN) if no input field widget is present
Claus Gittinger <cg@exept.de>
parents:
1457
diff
changeset
|
350 |
^ true. |
2249
150a384a74a6
code cleanup: use #contains/#conform instead of explicit loop
Claus Gittinger <cg@exept.de>
parents:
2008
diff
changeset
|
351 |
|
150a384a74a6
code cleanup: use #contains/#conform instead of explicit loop
Claus Gittinger <cg@exept.de>
parents:
2008
diff
changeset
|
352 |
"Modified: / 13-10-2006 / 12:56:02 / cg" |
1124 | 353 |
! ! |
354 |
||
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
355 |
!KeyboardProcessor methodsFor:'setup'! |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
356 |
|
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
357 |
addAutoAcceptListener:aListener |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
358 |
"add a aListener to my autoAcceptListeners. |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
359 |
Typically, inputFields add themself, to be notified (via requestForAutoAccept) |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
360 |
when the dialog is about to be closed with returnIsOK or accept. |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
361 |
(of course, other listeners are also invited ;-)" |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
362 |
|
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
363 |
autoAcceptListeners isNil ifTrue:[ |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
364 |
autoAcceptListeners := IdentitySet new. |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
365 |
]. |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
366 |
autoAcceptListeners add:aListener |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
367 |
! ! |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
368 |
|
1124 | 369 |
!KeyboardProcessor class methodsFor:'documentation'! |
370 |
||
371 |
version |
|
2447
ecb0212e1c8d
ALT-key processing disabled (temporarily)
Claus Gittinger <cg@exept.de>
parents:
2443
diff
changeset
|
372 |
^ '$Header: /cvs/stx/stx/libview2/KeyboardProcessor.st,v 1.45 2008-05-08 09:18:43 cg Exp $' |
1124 | 373 |
! ! |