简体   繁体   English

单击Smalltalk时视图变白

[英]View become white when I Click away Smalltalk

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 您好,所以我有一个Main应用程序,它绘制了一个Circle和一个矩形,但是当我单击它们时,它们消失了,这是我使用的代码

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 在ShapesView类中,我有一个Model访问器,并且此methode,我的Model和controller仍然为空

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.

What you need to do is to find out which method is being sent when the UI Element is gaining focus again. 您需要做的是找出当UI元素再次获得关注时正在发送哪种方法。 How this is done varies from Smalltalk dialect to dialect. 这样做的方式因Smalltalk方言而异。 The way, you have implemented this now just means you just draw it once. 这样,您现在实现的方式就意味着您只需绘制一次即可。 This does not mean it is being redrawn at all. 这并不意味着它完全被重绘。

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. 如您所见,为了使形状持久,图形应位于ShapeView类(实例侧)的“ displayOn:gc”方法(如JayK所述)中,该方法应执行您指定的图形:gc paint:ColorValue red 。

shape := MyRectangle origin: 2@2 extent: 50@75. shape:= MyRectangle起点:2 @ 2范围:50 @ 75。

shape displayFilledOn: gc. 形状displayFilledOn:gc。

gc paint: ColorValue blue. gc颜料:ColorValue蓝色。

shape := MyCircle center: 100@100 radius: 50. 形状:= MyCircle中心:100 @ 100半径:50。

shape displayFilledOn: gc. 形状displayFilledOn:gc。

The shapes could be created in an intializeComponents, but the api calls displayOn: whenever a re-display of the view is needed. 可以在intializeComponents中创建形状,但是只要需要重新显示视图,api就会调用displayOn:。
Changing the model or resizing the window will cause an invalidation and re-display. 更改模型或调整窗口大小将导致无效并重新显示。 hth - Arden Thomas hth-Arden Thomas

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM