How to update the appearance of a morph in mid-method?

Hernan Tylim htylim at yahoo.com.ar
Tue Dec 28 14:03:36 UTC 2004


Hi Jon,
	the #changed call is not really neccessary. It needs to only do the 
doOneCycle thing.

try this on a workspace:

m := Morph new.
m openInWorld.
m color: Color yellow.
(Delay forSeconds: 2) wait.
m color: Color blue.

select all and evaluate it. This code won´t work. But if you do:

m := Morph new.
m openInWorld.
m outermostWorldMorph doOneCycle.
m color: Color yellow.
m outermostWorldMorph doOneCycle.
(Delay forSeconds: 2) wait.
m color: Color blue.

it will.

Take into account that the 2 seconds delay is a no no. The way to do the 
delay is how you did it with the loop.

Regards,
Hernán

Jon Hylands wrote:
> On Mon, 27 Dec 2004 19:59:18 -0500, Jim Rosenberg <jr at amanue.com> wrote:
> 
> 
>>Well, I just tried this, and am still not seeing the color change.
> 
> 
> You need to do the following:
> 
> 	aMorph
> 		changeBorderColor;
> 		changed.
> 	Display forceDisplayUpdate.
> 	100 timesRepeat: [
> 		(Delay forMilliseconds: 20) wait.
> 		aMorph world doOneCycle].
> 	aMorph
> 		restoreBorderColor;
> 		changed.
> 	"The following line is optional, and probably not needed."
> 	Display forceDisplayUpdate.
> 
> To force the morph to redraw, you need to send #changed to it. After that,
> you need to force the redraw to the display. The delay as implemented above
> is just a simpler way of keeping the UI running while you're pausing.
> 
> Later,
> Jon
> 
> --------------------------------------------------------------
>    Jon Hylands      Jon at huv.com      http://www.huv.com/jon
> 
>   Project: Micro Seeker (Micro Autonomous Underwater Vehicle)
>            http://www.huv.com
> 
> 



More information about the Squeak-dev mailing list