[Newbies] LedMorph - step problem
FrankBz
kyotosong at libero.it
Sat Mar 6 16:25:46 UTC 2010
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.
More information about the Beginners
mailing list