author | Claus Gittinger <cg@exept.de> |
Thu, 09 Nov 2017 20:09:30 +0100 | |
changeset 6225 | 0122e4e6c587 |
parent 6082 | 8e35a927189c |
child 6590 | 7b30cb79318b |
permissions | -rw-r--r-- |
76 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
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 |
" |
|
2283 | 12 |
"{ Package: 'stx:libwidg' }" |
13 |
||
5323 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
76 | 16 |
Controller subclass:#ButtonController |
262 | 17 |
instanceVariableNames:'enableChannel pressChannel releaseChannel pressed active entered |
220
635d3f583f61
fast repeat if shift is pressed
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
18 |
isTriggerOnDown autoRepeat repeatBlock initialDelay repeatDelay |
5880 | 19 |
pressActionBlock releaseActionBlock isToggle isRadio buttonDown |
20 |
doubleClickActionBlock' |
|
262 | 21 |
classVariableNames:'' |
22 |
poolDictionaries:'' |
|
23 |
category:'Interface-Support-Controllers' |
|
76 | 24 |
! |
25 |
||
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
26 |
!ButtonController class methodsFor:'documentation'! |
76 | 27 |
|
28 |
copyright |
|
29 |
" |
|
30 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
31 |
All Rights Reserved |
|
32 |
||
33 |
This software is furnished under a license and may be used |
|
34 |
only in accordance with the terms of that license and with the |
|
35 |
inclusion of the above copyright notice. This software may not |
|
36 |
be provided or otherwise made available to, or used by, any |
|
37 |
other person. No title to or ownership of the software is |
|
38 |
hereby transferred. |
|
39 |
" |
|
40 |
! |
|
41 |
||
42 |
documentation |
|
43 |
" |
|
44 |
ButtonControllers are used with buttons and handle all user interaction. |
|
45 |
These are automatically created when a Button is created, therefore no manual |
|
46 |
action is required for creation. |
|
5584 | 47 |
In normal applications, you don't have to care for the controller; |
133 | 48 |
access to the controllers behavior is possible via messages to the button. |
125 | 49 |
(setting actions, controlling autorepeat etc.) |
76 | 50 |
|
972 | 51 |
A ButtonController supports 3 types of notifications: |
52 |
MVC change notification - as usual |
|
53 |
channel notifications - through the pressChannel/releaseChannels |
|
54 |
action callBack - through pressAction / releaseAction blocks. |
|
55 |
||
56 |
Notifications are made in the above order (i.e. an actionBlock sees the model |
|
57 |
already changed, if there is a model). |
|
58 |
||
59 |
Having multiple mechanisms here is both historic and to make the life |
|
5584 | 60 |
of simple applications easier - most buttons don't need a model or notification |
972 | 61 |
channels and simply perform some action. |
62 |
In general: actionBlocks are useful, if there is a single subject which |
|
63 |
needs to be told about the press (i.e. actionButtons); |
|
64 |
models should be used when the button represents some value in some other |
|
65 |
object. |
|
66 |
Channels are much like the MVC approach, however, these are useful if |
|
67 |
press/release/label etc. may come from different objects, and a single |
|
68 |
(synthetic) model does not make sense or is not appropriate. |
|
69 |
||
70 |
Actually, the channels are the most general - and the other mechanism could |
|
71 |
(and will, maybe) based upon them; after all, an actionBlock is a channel, |
|
72 |
whcih sends #value to its block .... |
|
73 |
||
74 |
||
75 |
||
133 | 76 |
See examples in the Button class. |
77 |
||
582 | 78 |
[Instance variables:] |
76 | 79 |
|
133 | 80 |
enableChannel <ValueHolder pressing is allowed (default: true) |
582 | 81 |
on Boolean> |
125 | 82 |
|
76 | 83 |
pressed <Boolean> true if currently pressed (read-only) |
125 | 84 |
|
76 | 85 |
entered <Boolean> true if the cursor is currently in this view |
125 | 86 |
|
118 | 87 |
isTriggerOnDown <Boolean> controls if the action should be executed on |
582 | 88 |
press or on release (default: on release). |
125 | 89 |
|
90 |
isToggle <Boolean> controls if the button should show toggle |
|
582 | 91 |
behavior (as opposed to one-shot behavior) |
125 | 92 |
|
76 | 93 |
pressActionBlock <Block> block to evaluate when pressed (default: noop) |
125 | 94 |
|
76 | 95 |
releaseActionBlock <Block> block to evaluate when released (default: noop) |
125 | 96 |
|
76 | 97 |
autoRepeat <Boolean> auto-repeats when pressed long enough (default: false) |
125 | 98 |
|
76 | 99 |
initialDelay <Number> seconds till first auto-repeat (default: 0.2) |
125 | 100 |
|
76 | 101 |
repeatDelay <Number> seconds of repeat intervall (default: 0.025) |
125 | 102 |
|
76 | 103 |
repeatBlock <Block> block evaluated for auto-repeat (internal) |
125 | 104 |
|
76 | 105 |
active <Boolean> true during action evaluation (internal) |
582 | 106 |
|
107 |
[author:] |
|
108 |
Claus Gittinger |
|
76 | 109 |
" |
110 |
! ! |
|
111 |
||
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
112 |
!ButtonController class methodsFor:'defaults'! |
76 | 113 |
|
114 |
defaultInitialDelay |
|
115 |
"when autorepeat is enabled, and button is not released, |
|
116 |
start repeating after initialDelay seconds" |
|
117 |
||
118 |
^ 0.2 |
|
200 | 119 |
! |
120 |
||
121 |
defaultRepeatDelay |
|
122 |
"when autorepeat is enabled, and button is not released, |
|
123 |
repeat every repeatDelay seconds" |
|
124 |
||
125 |
^ 0.025 |
|
76 | 126 |
! ! |
127 |
||
200 | 128 |
!ButtonController methodsFor:'accessing-behavior'! |
129 |
||
130 |
action:aBlock |
|
131 |
"convenient method: depending on the setting the triggerOnDown flag, |
|
347 | 132 |
either set the press-action & clear any release-action or |
200 | 133 |
vice versa, set the release-action and clear the press-action." |
76 | 134 |
|
200 | 135 |
isTriggerOnDown ifTrue:[ |
347 | 136 |
releaseActionBlock := nil. |
137 |
pressActionBlock := aBlock |
|
200 | 138 |
] ifFalse:[ |
347 | 139 |
releaseActionBlock := aBlock. |
140 |
pressActionBlock := nil |
|
2865 | 141 |
]. |
347 | 142 |
|
143 |
"Modified: 9.2.1996 / 22:41:22 / cg" |
|
200 | 144 |
! |
118 | 145 |
|
200 | 146 |
autoRepeat |
347 | 147 |
"turn on autorepeat. OBSOLETE; use #autoRepeat:" |
200 | 148 |
|
347 | 149 |
self autoRepeat:true. |
150 |
||
151 |
"Modified: 9.2.1996 / 22:42:46 / cg" |
|
118 | 152 |
! |
153 |
||
200 | 154 |
autoRepeat:aBoolean |
155 |
"turn on/off autorepeat" |
|
156 |
||
157 |
autoRepeat := aBoolean. |
|
1147 | 158 |
repeatBlock := MessageSend receiver:self selector:#repeat. "/ [self repeat] |
121 | 159 |
|
200 | 160 |
"Modified: 5.9.1995 / 22:06:00 / claus" |
1147 | 161 |
"Modified: 20.3.1997 / 21:56:13 / cg" |
200 | 162 |
! |
163 |
||
976 | 164 |
beButton |
5880 | 165 |
"make the receiver act like a button; that's the default, anyway" |
976 | 166 |
|
2345
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
167 |
"/ because I will be a trigger-on-up button |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
168 |
(isTriggerOnDown |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
169 |
and:[pressActionBlock notNil |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
170 |
and:[releaseActionBlock isNil]]) ifTrue:[ |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
171 |
pressActionBlock := releaseActionBlock. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
172 |
releaseActionBlock := nil. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
173 |
]. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
174 |
|
976 | 175 |
isTriggerOnDown := false. |
176 |
isToggle := false. |
|
177 |
isRadio := false. |
|
178 |
||
179 |
"Modified: 15.7.1996 / 13:42:15 / cg" |
|
180 |
"Created: 27.1.1997 / 13:30:11 / cg" |
|
181 |
! |
|
182 |
||
789 | 183 |
beRadioButton |
184 |
"make the receiver act like a radioButton; |
|
185 |
That is like a toggle, but do not allow turning myself off |
|
186 |
by buttonPress (instead, must be turned off by another button or programmatically)" |
|
187 |
||
2345
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
188 |
"/ because I will be a trigger-on-down button |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
189 |
(isTriggerOnDown not |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
190 |
and:[releaseActionBlock notNil |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
191 |
and:[pressActionBlock isNil]]) ifTrue:[ |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
192 |
pressActionBlock := releaseActionBlock. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
193 |
releaseActionBlock := nil. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
194 |
]. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
195 |
|
789 | 196 |
isTriggerOnDown := true. |
197 |
isToggle := false. |
|
198 |
isRadio := true. |
|
199 |
! |
|
200 |
||
200 | 201 |
beToggle |
202 |
"make the receiver act like a toggle" |
|
203 |
||
2345
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
204 |
"/ because I will be a trigger-on-down button |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
205 |
(isTriggerOnDown not |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
206 |
and:[releaseActionBlock notNil |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
207 |
and:[pressActionBlock isNil]]) ifTrue:[ |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
208 |
pressActionBlock := releaseActionBlock. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
209 |
releaseActionBlock := nil. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
210 |
]. |
3b69631b179b
when changing the trigger-on setting,
Claus Gittinger <cg@exept.de>
parents:
2312
diff
changeset
|
211 |
|
200 | 212 |
isTriggerOnDown := true. |
789 | 213 |
isToggle := true. |
214 |
isRadio := false. |
|
215 |
||
216 |
"Modified: 15.7.1996 / 13:42:15 / cg" |
|
121 | 217 |
! |
76 | 218 |
|
200 | 219 |
beTriggerOnDown |
220 |
"make the receiver act on button press" |
|
221 |
||
222 |
isTriggerOnDown := true |
|
223 |
! |
|
224 |
||
225 |
beTriggerOnUp |
|
226 |
"make the receiver act on button release" |
|
121 | 227 |
|
200 | 228 |
isTriggerOnDown := false |
229 |
! |
|
230 |
||
231 |
disable |
|
1832 | 232 |
"alternative invokation; redirected to basic mechanism" |
200 | 233 |
|
1832 | 234 |
self enabled:false |
235 |
||
236 |
"Modified: / 30.3.1999 / 14:50:12 / stefan" |
|
121 | 237 |
! |
238 |
||
5880 | 239 |
doubleClickAction |
240 |
"return the doubleClickAction; that's the block which gets evaluated |
|
241 |
when the button is double-clicked (if non-nil). |
|
242 |
Seldom used with buttons" |
|
243 |
||
244 |
^ doubleClickActionBlock |
|
245 |
! |
|
246 |
||
247 |
doubleClickAction:aBlock |
|
248 |
"define the action to be performed on double click" |
|
249 |
||
250 |
doubleClickActionBlock := aBlock. |
|
251 |
! |
|
252 |
||
200 | 253 |
enable |
1832 | 254 |
"alternative invokation; redirected to basic mechanism" |
255 |
||
256 |
self enabled:true |
|
257 |
||
258 |
"Modified: / 30.3.1999 / 14:50:01 / stefan" |
|
259 |
! |
|
121 | 260 |
|
1832 | 261 |
enabled:aBoolean |
262 |
"disable the button" |
|
263 |
||
264 |
enableChannel value ~~ aBoolean ifTrue:[ |
|
265 |
enableChannel value:aBoolean. |
|
266 |
"/ view redraw - not needed; I listen to enableChannel |
|
200 | 267 |
] |
1832 | 268 |
|
269 |
"Created: / 30.3.1999 / 14:49:05 / stefan" |
|
76 | 270 |
! |
271 |
||
200 | 272 |
isTriggerOnDown |
273 |
"return true, if I trigger on press |
|
274 |
(in contrast to triggering on up, which is the default)" |
|
275 |
||
276 |
^ isTriggerOnDown |
|
277 |
! |
|
278 |
||
279 |
pressAction |
|
5880 | 280 |
"return the pressAction; that's the block which gets evaluated |
200 | 281 |
when the button is pressed (if non-nil)" |
282 |
||
283 |
^ pressActionBlock |
|
284 |
! |
|
285 |
||
286 |
pressAction:aBlock |
|
287 |
"define the action to be performed on press" |
|
288 |
||
2865 | 289 |
pressActionBlock := aBlock. |
128 | 290 |
! |
291 |
||
200 | 292 |
releaseAction |
5880 | 293 |
"return the releaseAction; that's the block which gets evaluated |
294 |
when the button is released (if non-nil)" |
|
200 | 295 |
|
296 |
^ releaseActionBlock |
|
297 |
! |
|
298 |
||
299 |
releaseAction:aBlock |
|
300 |
"define the action to be performed on release" |
|
301 |
||
2865 | 302 |
releaseActionBlock := aBlock. |
128 | 303 |
! |
304 |
||
200 | 305 |
triggerOnDown:aBoolean |
306 |
"set/clear the flag which controls if the action block is to be evaluated |
|
307 |
on press or on release. |
|
308 |
(see also ST-80 compatibility methods beTriggerOn*)" |
|
309 |
||
310 |
isTriggerOnDown := aBoolean |
|
128 | 311 |
! ! |
312 |
||
145 | 313 |
!ButtonController methodsFor:'accessing-channels'! |
314 |
||
315 |
enableChannel |
|
602 | 316 |
"return the valueHolder holding the enable boolean value" |
145 | 317 |
|
318 |
^ enableChannel |
|
602 | 319 |
|
320 |
"Modified: 30.4.1996 / 15:09:30 / cg" |
|
145 | 321 |
! |
322 |
||
323 |
enableChannel:aValueHolder |
|
324 |
"set the valueHolder, which holds the enable boolean value" |
|
325 |
||
162 | 326 |
|wasEnabled| |
327 |
||
145 | 328 |
enableChannel notNil ifTrue:[ |
1447 | 329 |
wasEnabled := enableChannel value. |
330 |
enableChannel retractInterestsFor:self. |
|
162 | 331 |
] ifFalse:[ |
1447 | 332 |
wasEnabled := true |
145 | 333 |
]. |
334 |
enableChannel := aValueHolder. |
|
1837
bc7c89c82edd
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
335 |
aValueHolder onChangeSend:#enableStateChanged to:self. |
1447 | 336 |
|
162 | 337 |
enableChannel value ~~ wasEnabled ifTrue:[ |
1837
bc7c89c82edd
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
338 |
self enableStateChanged |
1447 | 339 |
|
145 | 340 |
] |
162 | 341 |
|
342 |
"Modified: 17.9.1995 / 19:41:18 / claus" |
|
145 | 343 |
! |
344 |
||
2312 | 345 |
pressChannel |
346 |
||
347 |
^ pressChannel |
|
348 |
! |
|
349 |
||
145 | 350 |
pressChannel:aChannel |
351 |
pressChannel := aChannel |
|
352 |
! |
|
353 |
||
2312 | 354 |
releaseChannel |
355 |
||
356 |
^ releaseChannel |
|
357 |
! |
|
358 |
||
145 | 359 |
releaseChannel:aChannel |
360 |
releaseChannel := aChannel |
|
361 |
! ! |
|
362 |
||
200 | 363 |
!ButtonController methodsFor:'accessing-state'! |
76 | 364 |
|
200 | 365 |
active |
366 |
"return true, if I am active; |
|
367 |
that is: currently performing my action. |
|
368 |
This query can be used to avoid multiple redraws." |
|
76 | 369 |
|
200 | 370 |
^ active |
128 | 371 |
! |
372 |
||
200 | 373 |
active:aBoolean |
374 |
active := aBoolean |
|
76 | 375 |
! |
376 |
||
200 | 377 |
enabled |
378 |
"return true, if I am enabled" |
|
128 | 379 |
|
200 | 380 |
^ enableChannel value |
76 | 381 |
! |
382 |
||
200 | 383 |
entered |
384 |
"return true, if the mouse pointer is currently in my view" |
|
155 | 385 |
|
200 | 386 |
^ entered |
387 |
! |
|
155 | 388 |
|
200 | 389 |
entered:aBoolean |
390 |
entered := aBoolean |
|
155 | 391 |
! |
392 |
||
200 | 393 |
pressed |
394 |
"return true, if I am pressed" |
|
76 | 395 |
|
200 | 396 |
^ pressed |
76 | 397 |
! |
398 |
||
200 | 399 |
pressed:aBoolean |
400 |
pressed ~~ aBoolean ifTrue:[ |
|
401 |
pressed := aBoolean. |
|
402 |
self performAction. |
|
118 | 403 |
]. |
404 |
! |
|
405 |
||
200 | 406 |
setPressed:aBoolean |
407 |
pressed := aBoolean. |
|
121 | 408 |
|
200 | 409 |
"Created: 14.11.1995 / 21:37:08 / cg" |
266 | 410 |
! |
411 |
||
412 |
toggle |
|
413 |
"toggle and perform the action" |
|
414 |
||
415 |
enableChannel value ifTrue:[ |
|
2312 | 416 |
self toggleNoAction. |
417 |
self performAction. |
|
418 |
view changed:#toggle with:pressed |
|
266 | 419 |
] |
420 |
! |
|
421 |
||
422 |
toggleNoAction |
|
423 |
"toggle, but do NOT perform any action" |
|
424 |
||
425 |
pressed ifTrue:[ |
|
1463
5eaeef9cb688
redraw early after a toggle (before telling the model).
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
426 |
view turnOff. |
5eaeef9cb688
redraw early after a toggle (before telling the model).
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
427 |
pressed := false. |
266 | 428 |
] ifFalse:[ |
1463
5eaeef9cb688
redraw early after a toggle (before telling the model).
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
429 |
view turnOn. |
5eaeef9cb688
redraw early after a toggle (before telling the model).
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
430 |
pressed := true. |
266 | 431 |
]. |
1463
5eaeef9cb688
redraw early after a toggle (before telling the model).
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
432 |
view repairDamage |
5eaeef9cb688
redraw early after a toggle (before telling the model).
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
433 |
|
5eaeef9cb688
redraw early after a toggle (before telling the model).
Claus Gittinger <cg@exept.de>
parents:
1447
diff
changeset
|
434 |
"Modified: / 4.3.1998 / 13:35:12 / cg" |
76 | 435 |
! ! |
436 |
||
437 |
!ButtonController methodsFor:'event handling'! |
|
438 |
||
2382 | 439 |
buttonMotion:buttonState x:x y:y |
1266 | 440 |
(x >= 0 and:[x < view width |
441 |
and:[y >= 0 and:[y < view height]]]) ifTrue:[ |
|
442 |
entered ifFalse:[ |
|
2382 | 443 |
self pointerEnter:buttonState x:x y:y |
444 |
] |
|
1266 | 445 |
] ifFalse:[ |
446 |
entered ifTrue:[ |
|
2382 | 447 |
self pointerLeave:buttonState |
448 |
] |
|
1266 | 449 |
] |
450 |
! |
|
451 |
||
200 | 452 |
buttonMultiPress:button x:x y:y |
5880 | 453 |
doubleClickActionBlock notNil ifTrue:[ |
454 |
doubleClickActionBlock valueWithOptionalArgument:view. |
|
455 |
^ self. |
|
456 |
]. |
|
200 | 457 |
^ self buttonPress:button x:x y:y |
458 |
! |
|
459 |
||
76 | 460 |
buttonPress:button x:x y:y |
1710 | 461 |
|wg| |
462 |
||
5075 | 463 |
"/ simulate momentary loss of focus to force accept into models in other components |
464 |
wg := view windowGroup. |
|
465 |
wg notNil ifTrue:[ |
|
466 |
wg focusMomentaryRelease. |
|
76 | 467 |
]. |
468 |
||
5075 | 469 |
(button == 1) ifFalse:[ |
470 |
^ super buttonPress:button x:x y:y |
|
1680
4c01dc0d5f1c
optional take focus on click
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
471 |
]. |
4c01dc0d5f1c
optional take focus on click
Claus Gittinger <cg@exept.de>
parents:
1540
diff
changeset
|
472 |
|
1128 | 473 |
buttonDown := true. |
474 |
||
133 | 475 |
enableChannel value ifTrue:[ |
789 | 476 |
isToggle ifTrue:[ |
477 |
self toggle. |
|
478 |
^ self |
|
479 |
]. |
|
480 |
isRadio ifTrue:[ |
|
481 |
pressed ifFalse:[ |
|
482 |
self toggle |
|
483 |
]. |
|
484 |
^ self |
|
485 |
]. |
|
118 | 486 |
|
789 | 487 |
pressed ifFalse:[ |
488 |
pressed := true. |
|
489 |
view showActive. |
|
5645 | 490 |
"/ make sure that a momentary press is visible |
491 |
view repairDamage. |
|
492 |
Delay waitForSeconds:0.1. |
|
76 | 493 |
|
789 | 494 |
(pressActionBlock notNil or:[model notNil]) ifTrue:[ |
495 |
" |
|
496 |
force output - so that button is drawn correctly in case |
|
497 |
of any long-computation (at high priority) |
|
498 |
" |
|
499 |
view flush. |
|
500 |
]. |
|
76 | 501 |
|
789 | 502 |
self performAction. |
2962 | 503 |
view notNil ifTrue:[ |
504 |
view flush. |
|
505 |
]. |
|
76 | 506 |
|
789 | 507 |
autoRepeat ifTrue:[ |
508 |
Processor addTimedBlock:repeatBlock afterSeconds:initialDelay |
|
509 |
] |
|
510 |
] |
|
76 | 511 |
] |
262 | 512 |
|
4412 | 513 |
"Modified: / 28-03-2012 / 13:08:38 / cg" |
76 | 514 |
! |
515 |
||
516 |
buttonRelease:button x:x y:y |
|
517 |
"button was released - if enabled, perform releaseaction" |
|
518 |
||
3918
b00bc734f3d8
preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents:
3849
diff
changeset
|
519 |
(button == 1) ifFalse:[ |
789 | 520 |
^ super buttonRelease:button x:x y:y |
76 | 521 |
]. |
118 | 522 |
|
1128 | 523 |
buttonDown := false. |
524 |
||
789 | 525 |
(isToggle or:[isRadio]) ifTrue:[ |
526 |
^ self |
|
118 | 527 |
]. |
528 |
||
76 | 529 |
pressed ifTrue:[ |
789 | 530 |
autoRepeat ifTrue:[ |
531 |
Processor removeTimedBlock:repeatBlock |
|
532 |
]. |
|
533 |
pressed := false. |
|
534 |
view showPassive. |
|
76 | 535 |
|
789 | 536 |
enableChannel value ifTrue:[ |
537 |
" |
|
538 |
only perform action if released within myself |
|
539 |
" |
|
540 |
((x >= 0) |
|
541 |
and:[x <= view width |
|
542 |
and:[y >= 0 |
|
543 |
and:[y <= view height]]]) ifTrue:[ |
|
544 |
(releaseActionBlock notNil or:[model notNil]) ifTrue:[ |
|
545 |
" |
|
546 |
force output - so that button is drawn correctly in case |
|
547 |
of any long-computation (at high priority) |
|
548 |
" |
|
549 |
view flush. |
|
550 |
]. |
|
76 | 551 |
|
789 | 552 |
self performAction. |
553 |
] |
|
554 |
] |
|
76 | 555 |
] |
262 | 556 |
|
1128 | 557 |
"Modified: 8.3.1997 / 00:04:19 / cg" |
76 | 558 |
! |
559 |
||
1837
bc7c89c82edd
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
560 |
enableStateChanged |
200 | 561 |
"this is sent, whenever the enable value has changed" |
76 | 562 |
|
1779
cd68cec6ebe8
change the cursor for disabled buttons.
Claus Gittinger <cg@exept.de>
parents:
1739
diff
changeset
|
563 |
view notNil ifTrue:[ |
cd68cec6ebe8
change the cursor for disabled buttons.
Claus Gittinger <cg@exept.de>
parents:
1739
diff
changeset
|
564 |
view invalidate "redraw". |
3849
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
565 |
view |
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
566 |
cursor:( |
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
567 |
enableChannel value |
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
568 |
ifTrue:[ Cursor hand ] |
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
569 |
ifFalse:[ Cursor normal ]) |
1779
cd68cec6ebe8
change the cursor for disabled buttons.
Claus Gittinger <cg@exept.de>
parents:
1739
diff
changeset
|
570 |
] |
200 | 571 |
|
572 |
"Modified: 17.9.1995 / 19:55:52 / claus" |
|
1191
98386e90229f
use asynchronous #invalidate when enable-state changes.
Claus Gittinger <cg@exept.de>
parents:
1168
diff
changeset
|
573 |
"Modified: 17.4.1997 / 01:53:14 / cg" |
76 | 574 |
! |
575 |
||
200 | 576 |
keyPress:key x:x y:y |
577 |
"trigger on Return and space, if I am the focusView of my group |
|
578 |
(i.e. if I got an explicit focus)" |
|
121 | 579 |
|
4488 | 580 |
"/ <resource: #keyboard (#Return)> |
3224 | 581 |
|
5323 | 582 |
|simulateClick| |
583 |
||
3803 | 584 |
view hasExplicitFocus ifTrue:[ |
5323 | 585 |
simulateClick := false. |
586 |
simulateClick := (key == Character space). |
|
587 |
simulateClick ifFalse:[ |
|
588 |
((key == #Return) and:[ isToggle not and:[isRadio not]]) ifTrue:[ |
|
589 |
simulateClick := true. |
|
590 |
]. |
|
591 |
]. |
|
592 |
||
593 |
simulateClick ifTrue:[ |
|
349
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
594 |
"just simulate a buttonPress/release here." |
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
595 |
self buttonPress:1 x:0 y:0. |
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
596 |
self buttonRelease:1 x:0 y:0. |
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
597 |
^ self. |
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
598 |
] |
200 | 599 |
]. |
600 |
view keyPress:key x:x y:y |
|
349
e4382398fc59
ignore Return key - its meant to close a box
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
601 |
|
4393 | 602 |
"Modified: / 07-03-2012 / 11:47:40 / cg" |
121 | 603 |
! |
604 |
||
605 |
performAction |
|
146 | 606 |
|action value| |
133 | 607 |
|
789 | 608 |
(isToggle or:[isRadio]) ifTrue:[ |
609 |
value := pressed |
|
133 | 610 |
] ifFalse:[ |
789 | 611 |
value := true |
133 | 612 |
]. |
76 | 613 |
|
125 | 614 |
" |
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
615 |
ST-80 style model notification ... |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
616 |
this updates the model (typically, a ValueHolder) |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
617 |
" |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
618 |
(isToggle |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
619 |
or:[(isTriggerOnDown and:[pressed]) |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
620 |
or:[isTriggerOnDown not and:[pressed not]]]) ifTrue:[ |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
621 |
"the ST-80 way of doing things" |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
622 |
view notNil ifTrue:[ |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
623 |
active := true. |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
624 |
view sendChangeMessageWith:value. |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
625 |
active := false. |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
626 |
]. |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
627 |
]. |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
628 |
|
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
629 |
" |
145 | 630 |
ST/X style actionBlock evaluation & channel notification ... |
125 | 631 |
" |
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
632 |
pressChannel notNil ifTrue:[ |
1095 | 633 |
pressed ifTrue:[ |
634 |
pressChannel value:true |
|
635 |
] |
|
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
636 |
]. |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
637 |
releaseChannel notNil ifTrue:[ |
1095 | 638 |
pressed ifFalse:[ |
639 |
releaseChannel value:true |
|
640 |
] |
|
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
641 |
]. |
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
642 |
|
76 | 643 |
pressed ifTrue:[ |
789 | 644 |
action := pressActionBlock. |
121 | 645 |
] ifFalse:[ |
789 | 646 |
action := releaseActionBlock. |
121 | 647 |
]. |
2865 | 648 |
|
125 | 649 |
action notNil ifTrue:[ |
789 | 650 |
active := true. |
2501 | 651 |
action valueWithOptionalArgument:value. |
789 | 652 |
active := false. |
125 | 653 |
]. |
76 | 654 |
|
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
655 |
"Modified: 24.1.1997 / 11:38:20 / cg" |
76 | 656 |
! |
657 |
||
2308 | 658 |
performShortcutAction |
659 |
enableChannel value ifTrue:[ |
|
660 |
isToggle ifTrue:[ |
|
661 |
self toggle. |
|
662 |
^ self |
|
663 |
]. |
|
664 |
isRadio ifTrue:[ |
|
665 |
pressed ifFalse:[ |
|
666 |
self toggle |
|
667 |
]. |
|
668 |
^ self |
|
669 |
]. |
|
670 |
||
671 |
self performAction. |
|
2312 | 672 |
] |
673 |
! |
|
2308 | 674 |
|
200 | 675 |
pointerEnter:state x:x y:y |
676 |
"mouse pointer entered my view. |
|
677 |
Redraw with enteredColors if they differ from the normal colors" |
|
678 |
||
679 |
entered := true. |
|
680 |
enableChannel value ifTrue:[ |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
681 |
pressed ifTrue:[ |
985
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
682 |
isTriggerOnDown ifFalse:[ |
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
683 |
view showActive. |
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
684 |
]. |
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
685 |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
686 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
687 |
reentered after a leave with mouse-button down; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
688 |
restart autorepeating and/or if I am a button with |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
689 |
triggerOnDown, show active again. |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
690 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
691 |
autoRepeat ifTrue:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
692 |
Processor addTimedBlock:repeatBlock afterSeconds:initialDelay |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
693 |
]. |
3849
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
694 |
]. |
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
695 |
view invalidate |
200 | 696 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
697 |
|
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
698 |
"Modified: 26.5.1996 / 18:09:06 / cg" |
76 | 699 |
! |
700 |
||
200 | 701 |
pointerLeave:state |
702 |
"mouse pointer left my view. |
|
703 |
Redraw with normal colors if they differ from enteredColors" |
|
76 | 704 |
|
200 | 705 |
entered := false. |
3471
24a5f40ff045
changed #pointerLeave: test for none nil view
Michael Beyl <mb@exept.de>
parents:
3224
diff
changeset
|
706 |
"/ sometimes could happen that the view becomes nil |
24a5f40ff045
changed #pointerLeave: test for none nil view
Michael Beyl <mb@exept.de>
parents:
3224
diff
changeset
|
707 |
view isNil ifTrue:[^ self]. |
24a5f40ff045
changed #pointerLeave: test for none nil view
Michael Beyl <mb@exept.de>
parents:
3224
diff
changeset
|
708 |
|
200 | 709 |
pressed ifTrue:[ |
985
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
710 |
isTriggerOnDown ifFalse:[ |
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
711 |
view showPassive. |
1168
231969f02a78
also invalidate in leave if not pressed
Claus Gittinger <cg@exept.de>
parents:
1147
diff
changeset
|
712 |
] ifTrue:[ |
231969f02a78
also invalidate in leave if not pressed
Claus Gittinger <cg@exept.de>
parents:
1147
diff
changeset
|
713 |
view invalidate |
985
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
714 |
]. |
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
715 |
|
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
716 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
717 |
leave with mouse-button down; |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
718 |
stop autorepeating and/or if I am a button with |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
719 |
action on release, show passive |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
720 |
" |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
721 |
autoRepeat ifTrue:[ |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
722 |
Processor removeTimedBlock:repeatBlock |
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
723 |
]. |
3849
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
724 |
]. |
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
725 |
enableChannel value ifTrue:[ |
da2d1a7a70bf
invalidate on pointer-enter/leave (vista radioButton)
Claus Gittinger <cg@exept.de>
parents:
3803
diff
changeset
|
726 |
view invalidate |
200 | 727 |
] |
711
c830bb66598b
use new #invalidate instead of redraw
Claus Gittinger <cg@exept.de>
parents:
704
diff
changeset
|
728 |
|
1168
231969f02a78
also invalidate in leave if not pressed
Claus Gittinger <cg@exept.de>
parents:
1147
diff
changeset
|
729 |
"Modified: 1.4.1997 / 13:27:32 / cg" |
76 | 730 |
! |
731 |
||
121 | 732 |
repeat |
733 |
"this is sent from the autorepeat-block, when the button has been pressed long |
|
734 |
enough; it simulates a release-press, by evaluating both release |
|
735 |
and press actions." |
|
76 | 736 |
|
220
635d3f583f61
fast repeat if shift is pressed
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
737 |
|dly| |
635d3f583f61
fast repeat if shift is pressed
Claus Gittinger <cg@exept.de>
parents:
203
diff
changeset
|
738 |
|
985
6e8a73b27390
perform action first, then reinstall autorepeat
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
739 |
(pressed and:[entered]) ifTrue:[ |
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
740 |
enableChannel value ifTrue:[ |
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
741 |
active ifFalse:[ |
5584 | 742 |
"/ don't repeat, if a release is pending ... |
2004
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
743 |
"/ (must check this, because the release event could |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
744 |
"/ stick in the queue, since exposes are handled first, |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
745 |
"/ which could lead to event processing to never happen) |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
746 |
(view sensor hasButtonReleaseEventFor:view) ifFalse:[ |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
747 |
self performAction. |
121 | 748 |
|
2004
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
749 |
autoRepeat ifTrue:[ |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
750 |
view graphicsDevice shiftDown ifTrue:[ |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
751 |
dly := repeatDelay / 4. |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
752 |
] ifFalse:[ |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
753 |
dly := repeatDelay |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
754 |
]. |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
755 |
Processor addTimedBlock:repeatBlock afterSeconds:dly |
0f035d5deb50
care for slow scrollers (lots of exposes) when autorepeating
Claus Gittinger <cg@exept.de>
parents:
1837
diff
changeset
|
756 |
] |
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
757 |
] |
2865 | 758 |
]. |
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
759 |
] |
76 | 760 |
] |
417
3f48ca2beb7d
use device shiftDown - NOT sensor shiftDown
Claus Gittinger <cg@exept.de>
parents:
349
diff
changeset
|
761 |
|
704 | 762 |
"Modified: 28.5.1996 / 20:21:24 / cg" |
1783 | 763 |
! |
764 |
||
765 |
requestAutoAccept |
|
5069 | 766 |
"request to autoAccept from a keyboardProcessor. |
5074 | 767 |
AutoAccept is always allowed" |
1783 | 768 |
|
2283 | 769 |
^ true. |
5074 | 770 |
"/ used to be: |
771 |
"/ ^ self enabled and:[view isDefault] |
|
76 | 772 |
! ! |
121 | 773 |
|
774 |
!ButtonController methodsFor:'initialization'! |
|
775 |
||
1266 | 776 |
controlInitialize |
777 |
active := false. |
|
778 |
entered := false. |
|
779 |
||
780 |
"Created: 24.7.1997 / 14:58:28 / cg" |
|
781 |
"Modified: 24.7.1997 / 14:59:06 / cg" |
|
782 |
! |
|
783 |
||
121 | 784 |
initialize |
6082 | 785 |
<modifier: #super> "must be called if redefined" |
786 |
||
121 | 787 |
super initialize. |
788 |
||
1540 | 789 |
enableChannel := ValueHolder with:true. |
1837
bc7c89c82edd
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
790 |
enableChannel onChangeSend:#enableStateChanged to:self. |
133 | 791 |
|
121 | 792 |
active := false. |
793 |
pressed := false. |
|
794 |
entered := false. |
|
795 |
autoRepeat := false. |
|
796 |
initialDelay := self class defaultInitialDelay. |
|
797 |
repeatDelay := self class defaultRepeatDelay. |
|
798 |
isTriggerOnDown := false. |
|
789 | 799 |
isToggle := isRadio := false. |
800 |
||
6082 | 801 |
"Modified: / 08-02-2017 / 00:34:34 / cg" |
1447 | 802 |
! |
803 |
||
1739 | 804 |
reinitialize |
805 |
active := false. |
|
2166
b6f4fb01cdeb
do not clobber pressed state in reinitialize
Claus Gittinger <cg@exept.de>
parents:
2004
diff
changeset
|
806 |
(isToggle or:[isRadio]) ifFalse:[ |
b6f4fb01cdeb
do not clobber pressed state in reinitialize
Claus Gittinger <cg@exept.de>
parents:
2004
diff
changeset
|
807 |
pressed := false. |
b6f4fb01cdeb
do not clobber pressed state in reinitialize
Claus Gittinger <cg@exept.de>
parents:
2004
diff
changeset
|
808 |
]. |
1739 | 809 |
entered := false. |
2166
b6f4fb01cdeb
do not clobber pressed state in reinitialize
Claus Gittinger <cg@exept.de>
parents:
2004
diff
changeset
|
810 |
|
b6f4fb01cdeb
do not clobber pressed state in reinitialize
Claus Gittinger <cg@exept.de>
parents:
2004
diff
changeset
|
811 |
"Modified: / 1.3.2000 / 15:17:10 / cg" |
1739 | 812 |
! |
813 |
||
1447 | 814 |
release |
815 |
"release all dependencies" |
|
816 |
||
817 |
enableChannel notNil ifTrue:[ |
|
818 |
enableChannel retractInterestsFor:self. |
|
819 |
enableChannel := nil. |
|
820 |
]. |
|
821 |
super release |
|
121 | 822 |
! ! |
200 | 823 |
|
971
8caaeb9d63fb
change the model before performing any actionBlock
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
824 |
!ButtonController class methodsFor:'documentation'! |
203 | 825 |
|
826 |
version |
|
5584 | 827 |
^ '$Header$' |
203 | 828 |
! ! |
4488 | 829 |