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