Hello so I have a Main application that draw a Circle and a rectangle but when I click away they juste disappear here is the code I use
initialize
shapesView := ShapesView new.
shapesModel := ShapesModel new.
shapesView model: shapesModel.
and I have the component initialisation in
postOpenWith: aBuilder
shapesView initializeComponents.
in the ShapesView class I have aModel accessor and this methode , my Model and controller are still empty
initializeComponents
| shape gc|
gc := self graphicsContext.
gc paint: ColorValue red.
shape := MyRectangle origin: 2@2 extent: 50@75.
shape displayFilledOn: gc.
gc paint: ColorValue blue.
shape := MyCircle center: 100@100 radius: 50.
shape displayFilledOn: gc.
As you found, for the shapes to be persistent, the drawing should be in a "displayOn: gc" method (as JayK mentioned) in the ShapeView class (instance side), which should do the drawing you specify: gc paint: ColorValue red.
shape := MyRectangle origin: 2@2 extent: 50@75.
shape displayFilledOn: gc.
gc paint: ColorValue blue.
shape := MyCircle center: 100@100 radius: 50.
shape displayFilledOn: gc.
The shapes could be created in an intializeComponents, but the api calls displayOn: whenever a re-display of the view is needed.
Changing the model or resizing the window will cause an invalidation and re-display. hth - Arden Thomas