我已经创建了 #SystemWindow 的子类#Casite1,我想控制窗口的初始位置。我怎么做?涉及班级 #RealEstateAgent ,但如何?课堂评论说
Responsible for real-estate management on the screen,
which is to say, controlling where new windows appear,
with what sizes, etc. 5/20/96 sw
所以我要求解释如何配置和使用#RealEstateAgent类。
注意:
答案 0 :(得分:1)
一种解决方案是绕过#RealEstateAgent类并编写自己的代码来处理SystemWindow新实例的初始大小和位置。
这可以通过覆盖SystemWindow>> openInWorld来实现:范围:
openInWorld: aWorld extent: extent
"This msg and its callees result in the window being activeOnlyOnTop"
aWorld addMorph: self.
self morphPosition:
(RealEstateAgent initialFrameFor: self world: aWorld) topLeft;
morphExtent: extent.
aWorld startSteppingSubmorphsOf: self.
"Do it deferred. Was needed for text cursor to start blinking
if (Preferences disable: #focusFollowsMouse) "
WorldState addDeferredUIMessage: [ self activate ]
替换
self morphPosition:
(RealEstateAgent initialFrameFor: self world: aWorld) topLeft;
morphExtent: extent.
计算
然后做
self morphPosition: thePositionOfTheWindow morphExtent: theExtentOfTheWindow.