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