[Newbies] Re: Implementing a simple timer

glenpaling slp5591 at me.com
Wed Dec 21 19:15:34 UTC 2011


I tried your timer, it steps every 10 ms on my system. You've encountered one
of the hazards of subclassing. TextMorph has complex behaviour which your
timer inherits. Somehow, it's overriding the stepTime method. You can prove
this by putting a halt in the stepTime method, it isn't called.

Rather than subclass TextMorph you could try making you're timer class
another, simpler, morph like a RectangleMorph. During initialization, add a
TextMorph as a subMorph (see code below). Make the step method update the
time and apply it to the contents of the TextMorph.

initialize

	super initialize.
	time := 0.
	textMorph := TextMorph new.
	self addMorph: textMorph.
	textMorph center: (self center).

--
View this message in context: http://forum.world.st/Implementing-a-simple-timer-tp4202411p4222889.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.


More information about the Beginners mailing list