Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I sleep for a few seconds in Smalltalk Pharo, and be able to interrupt this?

I'm debugging some keyboard event code and I want to loop with a sleep (to give me a chance to create the keyboard event), however when I do this Pharo won't let me quit with Command-. so debugging is difficult. I had to wait 500 seconds to fix something in the code below...

100 timesRepeat: [ 
    Transcript show: 'Type an a... '.
    (Delay forSeconds: 5) wait.
    (Sensor keyPressed: $a) ifTrue: [ Transcript show: 'you pressed a' ].
]

So how can I make Command-. work, or is there something more suitable than (Delay forSeconds: 5) wait.?

like image 437
Eric Clack Avatar asked Nov 03 '22 22:11

Eric Clack


1 Answers

Works fine in Squeak on Mac OS X (using peekKeyboardEvent, it does not have keyPressed:). So it's not your code's fault, interrupting this should work fine.

like image 197
Vanessa Freudenberg Avatar answered Dec 20 '22 03:12

Vanessa Freudenberg