1

I'm trying let two NSWindows to move together (NSWindows are Attached to each other). by using

- (void)windowDidMove:(NSNotification *)notification

But this method is lazy and it's not working live. Overriding setFrameOrigin and other setFrame methods did not work as well. I was wondering what is the best way to do this? I'll appreciate any suggestions with different approaches.

4

1 回答 1

1

Child Windows seem to be best suited for your situation.

They are simple enough to implement, and are done through the -addChildWindow:ordered: method of NSWindow. The reference explains it pretty well, so I'll just copy that here:

After the childWindow is added as a child of the window, it is maintained in relative position indicated by orderingMode for subsequent ordering operations involving either window. While this attachment is active, moving childWindow will not cause the window to move (as in sliding a drawer in or out), but moving the window will cause childWindow to move.

In essence, when you move the parent window, the child window will move with it without additional code. Sounds like what you want.

于 2012-09-30T21:46:36.503 回答