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