Let me rephrase the question:
How can I keep a child NSWindow (added to a main NSWindow using addChildWindow
) the same size as the main window?
Old question:
I have two NSWindow
s: an uiWindow and an openglWindow. The uiWindow is borderless and initially the same size as the openglWindow. I add it as a child window. I would like to make the uiWindow follow any size changes that the openglWindow undergoes. To do that, I've subscribed to the delegate of openglWindow and I'm listening to the windowWillResize
method. However, I'm confused now. I don't know which function to call on uiWindow to resize it. There are quite a few options:
setFrame: display:
`contentRectForFrameRect
frameRectForContentRect
Below is the initialization code for the child window.
NSRect uiWindowRect = [self.openglWindow convertRectToScreen:((NSView*)self.openglWindow.contentView).bounds];
NSWindow* uiWindow = [[NSWindow alloc] initWithContentRect:uiWindowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreNonretained defer:NO];
[self.openglWindow addChildWindow:uiWindow ordered:NSWindowAbove];