I'm trying to do something that should be very simple. I have a clock model that I want to tick over every second. Then I want to hand that model to a Morphic viewer to display.
I initially set up a ticker process, based on some code in Mark Guzdial's Squeak&MMA book, section 4.2. It worked fine, except periodically morphic windows that were being updated would be trashed.
So, figuring that I had an unfortunate timing issue between the Morphic updater and the asynch process, I changed my clock model to extend Morph and use the #step method to update the clock (which led to a crash documented on Mantis, but I was directed to a work-around). It now works fine, except the step method gets called once for every view I have open, as well as the intended one, so my clock goes up in increments of 2 or 3 seconds per second.
My original thought was to have the ticker insert events into Morphic's event queue, but (a) I couldn't quite track it down, and (b) from what I found, it seemed to test the class of the events rather than simply dispatch them.
Help!
Thanks ../Dave
Dave Mason wrote:
I'm trying to do something that should be very simple. I have a clock model that I want to tick over every second. Then I want to hand that model to a Morphic viewer to display.
I initially set up a ticker process, based on some code in Mark Guzdial's Squeak&MMA book, section 4.2. It worked fine, except periodically morphic windows that were being updated would be trashed.
So, figuring that I had an unfortunate timing issue between the Morphic updater and the asynch process, I changed my clock model to extend Morph and use the #step method to update the clock (which led to a crash documented on Mantis, but I was directed to a work-around). It now works fine, except the step method gets called once for every view I have open, as well as the intended one, so my clock goes up in increments of 2 or 3 seconds per second.
My original thought was to have the ticker insert events into Morphic's event queue, but (a) I couldn't quite track it down, and (b) from what I found, it seemed to test the class of the events rather than simply dispatch them.
The step method is not accurate enough to simulate a clock. Time between steps vary and your clock will soon be out of sync. You can however use it to sync up to Time>>now and update the morph accordingly. Karl
Karl wrote:
The step method is not accurate enough to simulate a clock. Time between steps vary and your clock will soon be out of sync. You can however use it to sync up to Time>>now and update the morph accordingly.
But I don't necessarily want the clock to track the real-world time. And I can live with the inaccuracies for this situation.
How does one do this really?
Thanks ../Dave
karl wrote:
Dave Mason wrote:
I'm trying to do something that should be very simple. I have a clock model that I want to tick over every second. Then I want to hand that model to a Morphic viewer to display.
I initially set up a ticker process, based on some code in Mark Guzdial's Squeak&MMA book, section 4.2. It worked fine, except periodically morphic windows that were being updated would be trashed.
So, figuring that I had an unfortunate timing issue between the Morphic updater and the asynch process, I changed my clock model to extend Morph and use the #step method to update the clock (which led to a crash documented on Mantis, but I was directed to a work-around). It now works fine, except the step method gets called once for every view I have open, as well as the intended one, so my clock goes up in increments of 2 or 3 seconds per second.
My original thought was to have the ticker insert events into Morphic's event queue, but (a) I couldn't quite track it down, and (b) from what I found, it seemed to test the class of the events rather than simply dispatch them.
The step method is not accurate enough to simulate a clock. Time between steps vary and your clock will soon be out of sync. You can however use it to sync up to Time>>now and update the morph accordingly.
Look at class ClockMorph
Karl
squeak-dev@lists.squeakfoundation.org