9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
13 Controller subclass:#ButtonController |
13 Controller subclass:#ButtonController |
14 instanceVariableNames:'enableChannel pressChannel releaseChannel pressed active entered |
14 instanceVariableNames:'enableChannel pressChannel releaseChannel pressed active entered |
15 isTriggerOnDown autoRepeat repeatBlock initialDelay repeatDelay |
15 isTriggerOnDown autoRepeat repeatBlock initialDelay repeatDelay |
16 pressActionBlock releaseActionBlock isToggle' |
16 pressActionBlock releaseActionBlock isToggle' |
17 classVariableNames:'' |
17 classVariableNames:'' |
18 poolDictionaries:'' |
18 poolDictionaries:'' |
19 category:'Interface-Support-Controllers' |
19 category:'Interface-Support-Controllers' |
20 ! |
20 ! |
21 |
21 |
22 !ButtonController class methodsFor:'documentation'! |
22 !ButtonController class methodsFor:'documentation'! |
23 |
23 |
24 copyright |
24 copyright |
317 ^ self buttonPress:button x:x y:y |
317 ^ self buttonPress:button x:x y:y |
318 ! |
318 ! |
319 |
319 |
320 buttonPress:button x:x y:y |
320 buttonPress:button x:x y:y |
321 (button == 1 or:[button == #select]) ifFalse:[ |
321 (button == 1 or:[button == #select]) ifFalse:[ |
322 ^ super buttonPress:button x:x y:y |
322 ^ super buttonPress:button x:x y:y |
323 ]. |
323 ]. |
324 |
324 |
325 enableChannel value ifTrue:[ |
325 enableChannel value ifTrue:[ |
326 isToggle ifTrue:[ |
326 isToggle ifTrue:[ |
327 self toggle. |
327 self toggle. |
328 ^ self |
328 ^ self |
329 ]. |
329 ]. |
330 |
330 |
331 pressed ifFalse:[ |
331 pressed ifFalse:[ |
332 pressed := true. |
332 pressed := true. |
333 view showActive. |
333 view showActive. |
334 |
334 |
335 (pressActionBlock notNil or:[model notNil]) ifTrue:[ |
335 (pressActionBlock notNil or:[model notNil]) ifTrue:[ |
336 " |
336 " |
337 force output - so that button is drawn correctly in case |
337 force output - so that button is drawn correctly in case |
338 of any long-computation (at high priority) |
338 of any long-computation (at high priority) |
339 " |
339 " |
340 view device flush. |
340 view flush. |
341 ]. |
341 ]. |
342 |
342 |
343 self performAction. |
343 self performAction. |
344 |
344 |
345 autoRepeat ifTrue:[ |
345 autoRepeat ifTrue:[ |
346 Processor addTimedBlock:repeatBlock afterSeconds:initialDelay |
346 Processor addTimedBlock:repeatBlock afterSeconds:initialDelay |
347 ] |
347 ] |
348 ] |
348 ] |
349 ] |
349 ] |
|
350 |
|
351 "Modified: 16.12.1995 / 17:31:55 / cg" |
350 ! |
352 ! |
351 |
353 |
352 buttonRelease:button x:x y:y |
354 buttonRelease:button x:x y:y |
353 "button was released - if enabled, perform releaseaction" |
355 "button was released - if enabled, perform releaseaction" |
354 |
356 |
355 (button == 1 or:[button == #select]) ifFalse:[ |
357 (button == 1 or:[button == #select]) ifFalse:[ |
356 ^ super buttonRelease:button x:x y:y |
358 ^ super buttonRelease:button x:x y:y |
357 ]. |
359 ]. |
358 |
360 |
359 isToggle ifTrue:[ |
361 isToggle ifTrue:[ |
360 ^ self |
362 ^ self |
361 ]. |
363 ]. |
362 |
364 |
363 pressed ifTrue:[ |
365 pressed ifTrue:[ |
364 autoRepeat ifTrue:[ |
366 autoRepeat ifTrue:[ |
365 Processor removeTimedBlock:repeatBlock |
367 Processor removeTimedBlock:repeatBlock |
366 ]. |
368 ]. |
367 pressed := false. |
369 pressed := false. |
368 view showPassive. |
370 view showPassive. |
369 |
371 |
370 enableChannel value ifTrue:[ |
372 enableChannel value ifTrue:[ |
371 " |
373 " |
372 only perform action if released within myself |
374 only perform action if released within myself |
373 " |
375 " |
374 ((x >= 0) |
376 ((x >= 0) |
375 and:[x <= view width |
377 and:[x <= view width |
376 and:[y >= 0 |
378 and:[y >= 0 |
377 and:[y <= view height]]]) ifTrue:[ |
379 and:[y <= view height]]]) ifTrue:[ |
378 (releaseActionBlock notNil or:[model notNil]) ifTrue:[ |
380 (releaseActionBlock notNil or:[model notNil]) ifTrue:[ |
379 " |
381 " |
380 force output - so that button is drawn correctly in case |
382 force output - so that button is drawn correctly in case |
381 of any long-computation (at high priority) |
383 of any long-computation (at high priority) |
382 " |
384 " |
383 view device flush. |
385 view flush. |
384 ]. |
386 ]. |
385 |
387 |
386 self performAction. |
388 self performAction. |
387 ] |
389 ] |
388 ] |
390 ] |
389 ] |
391 ] |
|
392 |
|
393 "Modified: 16.12.1995 / 17:32:09 / cg" |
390 ! |
394 ! |
391 |
395 |
392 enableStateChange |
396 enableStateChange |
393 "this is sent, whenever the enable value has changed" |
397 "this is sent, whenever the enable value has changed" |
394 |
398 |