author | fm |
Mon, 23 Apr 2007 11:32:45 +0200 | |
changeset 2323 | c038faba10bf |
parent 2249 | 150a384a74a6 |
child 2337 | 1ed848a70875 |
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:'' |
|
19 |
category:'Interface-Support-UI' |
|
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 |
|
92 |
#'Cmd_L' #'Cmd_R' #'Cmd' |
|
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 |
105 |
"returns true if the key event is a mnemonic key |
|
106 |
" |
|
107 |
|rawKey| |
|
108 |
||
109 |
rawKey := aKeyEvent rawKey. |
|
1443 | 110 |
^ rawKey size == 4 and:[rawKey startsWith:'Cmd'] |
111 |
! ! |
|
1422 | 112 |
|
1763 | 113 |
!KeyboardProcessor methodsFor:'Compatibility-VW'! |
1124 | 114 |
|
115 |
keyboardConsumers |
|
116 |
^ #() |
|
117 |
||
118 |
"Created: 6.3.1997 / 15:16:32 / cg" |
|
119 |
! |
|
120 |
||
121 |
removeKeyboardReceiver:aController |
|
122 |
||
123 |
"Created: / 31.10.1997 / 01:56:54 / cg" |
|
124 |
! |
|
125 |
||
126 |
sendKeyboardTo:aController |
|
127 |
||
128 |
"Created: / 31.10.1997 / 01:57:15 / cg" |
|
129 |
! |
|
130 |
||
131 |
setActive:aWidget |
|
132 |
||
133 |
"Created: 3.3.1997 / 18:31:09 / cg" |
|
134 |
! ! |
|
135 |
||
136 |
!KeyboardProcessor methodsFor:'accessing'! |
|
137 |
||
1251 | 138 |
addAccelerator:aKey action:aSelectorOrBlock |
139 |
"add a global accelerator - these are handled even if no corresponding |
|
140 |
menu shortcut is defined" |
|
141 |
||
142 |
globalAccelerators isNil ifTrue:[ |
|
143 |
globalAccelerators := Dictionary new |
|
144 |
]. |
|
145 |
globalAccelerators at:aKey put:aSelectorOrBlock |
|
146 |
! |
|
147 |
||
1983 | 148 |
componentWithInitialFocus |
149 |
^ componentWithInitialFocus |
|
150 |
! |
|
151 |
||
152 |
componentWithInitialFocus:aComponent |
|
153 |
componentWithInitialFocus := aComponent |
|
154 |
! |
|
155 |
||
1124 | 156 |
escapeIsCancelInDialog:aBoolean |
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
157 |
"set the escapeIsCancel flag. |
1635 | 158 |
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
|
159 |
|
1124 | 160 |
escapeIsCancelInDialog := aBoolean |
161 |
! |
|
162 |
||
163 |
menuBar |
|
164 |
"return the value of the instance variable 'menuBar' (automatically generated)" |
|
165 |
||
1443 | 166 |
^ menuBar |
167 |
! |
|
1124 | 168 |
|
169 |
menuBar:something |
|
170 |
"set the value of the instance variable 'menuBar' (automatically generated)" |
|
171 |
||
1443 | 172 |
menuBar := something. |
173 |
! |
|
1124 | 174 |
|
175 |
returnIsOKInDialog:aBoolean |
|
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
176 |
"set the returnIsOK flag. |
1635 | 177 |
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
|
178 |
|
1124 | 179 |
returnIsOKInDialog := aBoolean |
180 |
! ! |
|
181 |
||
182 |
!KeyboardProcessor methodsFor:'event handling'! |
|
183 |
||
1135 | 184 |
processEvent:event forModalView:modalTopOrNil |
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
185 |
"process a key-event; return true, if handled & eaten; false if not. |
1251 | 186 |
Here, first, we look for a globalAccelerator, |
187 |
then for Return and Escape in modal applications, |
|
188 |
(which lead to Accept & Cancel resp.) |
|
189 |
Finally, menu-shortcuts are handled." |
|
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
190 |
|
2007
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
191 |
|key rawKey topView wg app view action explicitFocusView focusView| |
1124 | 192 |
|
193 |
view := event view. |
|
194 |
||
195 |
event isKeyPressEvent ifTrue:[ |
|
196 |
key := event key. |
|
1448
0c7834bd6c0f
early bailOut for cursorKeys (do not check for shortCuts)
Claus Gittinger <cg@exept.de>
parents:
1445
diff
changeset
|
197 |
rawKey := event rawKey. |
1135 | 198 |
topView := modalTopOrNil ? view topView. |
1636
c9ed206b5d32
escapeIsCancel/returnIsOK in popup with same app as mainapp
ca
parents:
1635
diff
changeset
|
199 |
|
1445
50bf6580e064
care for topViews without windowGroup (which should not happen - but...)
tm
parents:
1443
diff
changeset
|
200 |
wg := topView windowGroup. |
1124 | 201 |
app := topView application. |
202 |
||
1251 | 203 |
"/ how about global accelerators ? |
204 |
(globalAccelerators notNil |
|
205 |
and:[(action := globalAccelerators at:key ifAbsent:nil) notNil]) |
|
206 |
ifTrue:[ |
|
1492 | 207 |
event consumed:true. |
1251 | 208 |
action isSymbol ifTrue:[ |
1422 | 209 |
app notNil ifTrue:[ |
210 |
action numArgs == 1 ifTrue:[ |
|
211 |
app perform:action with:event |
|
212 |
] ifFalse:[ |
|
213 |
app perform:action |
|
214 |
]. |
|
215 |
] |
|
1251 | 216 |
] ifFalse:[ |
217 |
action numArgs == 1 ifTrue:[ |
|
218 |
action value:event |
|
219 |
] ifFalse:[ |
|
220 |
action value |
|
221 |
] |
|
222 |
]. |
|
1492 | 223 |
"/ ^ true |
224 |
^ event consumed |
|
1251 | 225 |
]. |
1488
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
226 |
|
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
227 |
topView isModal ifTrue:[ |
1637 | 228 |
(key == #Return and:[returnIsOKInDialog ? true]) ifTrue:[ |
229 |
(wg notNil |
|
2007
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
230 |
and:[(explicitFocusView := wg explicitFocusView) isNil |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
231 |
or:[ explicitFocusView isKeyboardConsumer not |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
232 |
or:[ explicitFocusView isInputField ] ] |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
233 |
]) ifTrue:[ |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
234 |
((focusView := wg focusView) notNil and:[focusView isTextView]) ifTrue:[ |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
235 |
focusView isInputField ifFalse:[ |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
236 |
"/ modalBox with a TextView |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
237 |
^ false |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
238 |
]. |
2008
bc367a4d7d6a
kludge for subcanvas-inputfields
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
239 |
"/ this is a kludge for subcanvas' input-fields, which |
bc367a4d7d6a
kludge for subcanvas-inputfields
Claus Gittinger <cg@exept.de>
parents:
2007
diff
changeset
|
240 |
"/ are not affected by #requestGlobalAutoAccept below. |
2007
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
241 |
focusView isAcceptOnReturn ifTrue:[ |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
242 |
focusView accept |
014e4bfe31f1
must accept an inputField before
Claus Gittinger <cg@exept.de>
parents:
2006
diff
changeset
|
243 |
]. |
2006
83d2e7259fcf
ignore return (do not close) if the current
Claus Gittinger <cg@exept.de>
parents:
1983
diff
changeset
|
244 |
]. |
83d2e7259fcf
ignore return (do not close) if the current
Claus Gittinger <cg@exept.de>
parents:
1983
diff
changeset
|
245 |
|
1488
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
246 |
self requestGlobalAutoAccept ifFalse:[^ true]. |
1636
c9ed206b5d32
escapeIsCancel/returnIsOK in popup with same app as mainapp
ca
parents:
1635
diff
changeset
|
247 |
|
c9ed206b5d32
escapeIsCancel/returnIsOK in popup with same app as mainapp
ca
parents:
1635
diff
changeset
|
248 |
"/ 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
|
249 |
"/ 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
|
250 |
(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
|
251 |
app doAcceptByReturnKey. |
1488
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
252 |
] ifFalse:[ |
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
253 |
"/ oldStyle modalBox - for now, let Box handle it itself |
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
254 |
^ false |
1422 | 255 |
]. |
1134
758151d73aac
only do autoAccept, if there is no focus view.
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
256 |
^ true |
758151d73aac
only do autoAccept, if there is no focus view.
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
257 |
]. |
1124 | 258 |
]. |
1637 | 259 |
(key == #Escape and:[escapeIsCancelInDialog ? true]) ifTrue:[ |
1636
c9ed206b5d32
escapeIsCancel/returnIsOK in popup with same app as mainapp
ca
parents:
1635
diff
changeset
|
260 |
"/ 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
|
261 |
"/ 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
|
262 |
(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
|
263 |
app doCancelByEscapeKey. |
1488
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
264 |
] ifFalse:[ |
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
265 |
"/ oldStyle modalBox - for now, let Box handle it itself |
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
266 |
^ false |
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
267 |
]. |
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
268 |
^ true |
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
269 |
]. |
1422 | 270 |
]. |
1488
9fa3505d2d85
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
1458
diff
changeset
|
271 |
|
1455
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
272 |
wg notNil ifTrue:[ |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
273 |
(self class isMnemonicKeyEvent:event) ifTrue:[ |
1456 | 274 |
"/Transcript showCR:event rawKey. |
275 |
"/Transcript showCR:event key. |
|
1455
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
276 |
(wg processMnemonic:event) ifTrue:[ |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
277 |
^ true |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
278 |
] |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
279 |
]. |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
280 |
(self class isKeyEventIgnoredAsShortcut:event) ifFalse:[ |
1456 | 281 |
"/Transcript showCR:event rawKey. |
282 |
"/Transcript showCR:event key. |
|
1455
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
283 |
(wg processShortcut:event) ifTrue:[ |
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
284 |
^ true |
1445
50bf6580e064
care for topViews without windowGroup (which should not happen - but...)
tm
parents:
1443
diff
changeset
|
285 |
]. |
1124 | 286 |
]. |
1422 | 287 |
]. |
1124 | 288 |
]. |
289 |
||
1423 | 290 |
"/ let view dispatch it. |
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
291 |
^ false |
1455
6d385add9b96
shortcut key processing (too slow)
Claus Gittinger <cg@exept.de>
parents:
1453
diff
changeset
|
292 |
|
1552 | 293 |
"Modified: / 23.12.2001 / 13:12:55 / cg" |
1423 | 294 |
! |
1124 | 295 |
|
296 |
requestForWindowClose |
|
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
297 |
"about to close the window." |
1124 | 298 |
|
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
299 |
^ true |
1124 | 300 |
! |
301 |
||
302 |
requestGlobalAutoAccept |
|
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
303 |
"about to close the window via return ok accept. |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
304 |
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
|
305 |
did." |
1124 | 306 |
|
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
307 |
autoAcceptListeners notNil ifTrue:[ |
2249
150a384a74a6
code cleanup: use #contains/#conform instead of explicit loop
Claus Gittinger <cg@exept.de>
parents:
2008
diff
changeset
|
308 |
^ autoAcceptListeners conform:[:aListener | (aListener requestAutoAccept)] |
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
309 |
]. |
1458
43c22152a2f5
accept autoAccept (RETURN) if no input field widget is present
Claus Gittinger <cg@exept.de>
parents:
1457
diff
changeset
|
310 |
"/ 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
|
311 |
"/ ^ false <- wrong. |
43c22152a2f5
accept autoAccept (RETURN) if no input field widget is present
Claus Gittinger <cg@exept.de>
parents:
1457
diff
changeset
|
312 |
^ true. |
2249
150a384a74a6
code cleanup: use #contains/#conform instead of explicit loop
Claus Gittinger <cg@exept.de>
parents:
2008
diff
changeset
|
313 |
|
150a384a74a6
code cleanup: use #contains/#conform instead of explicit loop
Claus Gittinger <cg@exept.de>
parents:
2008
diff
changeset
|
314 |
"Modified: / 13-10-2006 / 12:56:02 / cg" |
1124 | 315 |
! ! |
316 |
||
1128
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
317 |
!KeyboardProcessor methodsFor:'setup'! |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
318 |
|
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
319 |
addAutoAcceptListener:aListener |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
320 |
"add a aListener to my autoAcceptListeners. |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
321 |
Typically, inputFields add themself, to be notified (via requestForAutoAccept) |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
322 |
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
|
323 |
(of course, other listeners are also invited ;-)" |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
324 |
|
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
325 |
autoAcceptListeners isNil ifTrue:[ |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
326 |
autoAcceptListeners := IdentitySet new. |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
327 |
]. |
7810bca304e3
added autoAccept (editFields in dialogs)
Claus Gittinger <cg@exept.de>
parents:
1124
diff
changeset
|
328 |
autoAcceptListeners add:aListener |
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 |
|
1124 | 331 |
!KeyboardProcessor class methodsFor:'documentation'! |
332 |
||
333 |
version |
|
2249
150a384a74a6
code cleanup: use #contains/#conform instead of explicit loop
Claus Gittinger <cg@exept.de>
parents:
2008
diff
changeset
|
334 |
^ '$Header: /cvs/stx/stx/libview2/KeyboardProcessor.st,v 1.37 2006-10-13 11:03:39 cg Exp $' |
1124 | 335 |
! ! |