[squeak-dev] "Resettable" Delay?
Jim Rosenberg
jr at amanue.com
Sun May 19 05:50:04 UTC 2019
I'm in the midst of a project in which I'm adding sound to some artistic
work I've been doing in Squeak for quite a few years now. I want a sound to
be played when (1) the mouse cursor enters a morph which is one of my own
subclasses of RectangleMorph; and then (2) the mouse cursor becomes
"quiet". Maybe this is not the right way to do this, but here's how I'm
thinking of doing it:
On mouseEnter, create a Delay and then fork a process which waits on the
Delay and plays the sound. (Duration of the Delay is an artistic decision
based on context.)
On mouseMove, if the Delay is notNil and is being waited on, "reset it".
On mouseLeave, kill the process waiting on the Delay if it hasn't already
fired.
It looks to me from reading the code (Squeak 4.3) that I can reset the
Delay using the Delay class method scheduleDelay: -- but [I haven't tried
it yet ...] this makes me nervous. scheduleDelay: is labelled Private. I
think that's telling me that calling this method from application code is a
No-no. I'm also nervous about what I might need to do regarding the
semaphore.
Comments please? Is there an easier way to do this? I need some way to
reset a Delay that's already being waited on to the original duration.
-Thanks in advance, Jim
More information about the Squeak-dev
mailing list
|