[Newbies] LedMorph - step problem
Jerome Peace
peace_the_dreamer at yahoo.com
Sun Mar 7 03:01:14 UTC 2010
Hi Frank,
I haven't tried the example yet. But I know from my own work that when you don't want steps #wantsSteps should return false. Otherwise each time you pick your morph up and drop it the system restarts stepping.
so
wantsSteps (ck the spelling)
^ time isNil
and
stopStepping
super stopStepping
time := nil .
startStepping
super startStepping
time := Time now.
Hth,
Yours in curiosity and service, --Jerome Peace
--- On Sat, 3/6/10, FrankBz <kyotosong at libero.it> wrote:
> From: FrankBz <kyotosong at libero.it>
> Subject: [Newbies] LedMorph - step problem
> To: beginners at lists.squeakfoundation.org
> Date: Saturday, March 6, 2010, 11:25 AM
>
> Hi, I'm trying to write a LedMorph that shows the actual
> time. It should have
> also two buttons, 'quit' which closes the frame and 'stop'
> which should stop
> the clock.
> Unfortunately the stop button does not work and I can't
> figure out where's
> the problem.
> Even by trying to send the stopStepping message manually
> from a workspace
> the LedMorph doesn't stop stepping.
> Does anyone know what's the problem?
>
> I post the code, please tell me what I'm doing wrong.
>
> -> OriginalLed class has messages: initialize, step
> (they overwrite ancestor
> messages to set desired behavior)
>
> LedMorph subclass: #OriginalLed
> instanceVariableNames: 'time'
> classVariableNames: ''
> poolDictionaries: ''
> category: 'MyLed'
>
> initialize
> super initialize .
> time := Time new .
> self chars: 8 .
> self flash: true .
> self extent: (100 at 100) .
> self position: (200 at 150) .
>
> step
> time := Time now .
> self string: time print24 .
>
> -> LedFrame is a subclass of AlignmentMorph, which
> contains the OriginalLed
> and buttons. It defines 4 messages:
> -> initialize, addControls, addLed, stopStepping
>
> AlignmentMorph subclass: #LedFrame
> instanceVariableNames: 'controls led'
> classVariableNames: ''
> poolDictionaries: ''
> category: 'MyLed'
>
> initialize
> super initialize .
> self listDirection: #bottomToTop .
> self position: (200 @ 150) .
> self addControls .
> self addLed .
> self openInWorld .
>
> addControls
> controls := AlignmentMorph new
> listDirection: #rightToLeft .
>
> controls addMorph: (SimpleButtonMorph
> new target: led; label: 'stop';
> actionSelector: #stopStepping) .
> controls addMorph: (SimpleButtonMorph
> new target: self; label: 'quit';
> actionSelector: #delete) .
> self addMorph: controls .
>
> addLed
> led := OriginalLed new .
> self addMorph: led .
>
> stopStepping
> led stopStepping .
>
> I didn't write any comment inside the code, since it's very
> simple to
> understand.
> Sorry if I misspelled any term or said anything wrong, I'm
> a real squeak
> beginner.
> --
> View this message in context: http://n4.nabble.com/LedMorph-step-problem-tp1582908p1582908.html
> Sent from the Squeak - Beginners mailing list archive at
> Nabble.com.
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
More information about the Beginners
mailing list