2

我创建了#SystemWindow 的子类#Mosaic1 我想控制窗口的初始位置。我怎么做?涉及#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。

笔记:

  • #RealEstateAgent是单身人士。它只有类侧方法
  • 它仅由#SystemWindow引用
  • 一个新的 SystemWindow 从 RealEstateAgent类>> standardWindowExtent中获取其初始范围
4

1 回答 1

1

一种解决方案是绕过类#RealEstateAgent 并编写自己的代码来处理SystemWindow 新实例的初始大小和位置。

这可以通过覆盖 SystemWindow>>openInWorld:extent 来完成:

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.
于 2013-12-15T23:55:33.610 回答