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