Setting Position of NSWindow before Display

Posted by Armin Ronacher on Stack Overflow See other posts from Stack Overflow or by Armin Ronacher
Published on 2010-05-22T19:42:53Z Indexed on 2010/05/22 19:50 UTC
Read the original article Hit count: 267

Filed under:

Right now I'm setting the position of a window that is about to open like this:

-(void) setActiveNodeDialog:(ISKNodeDialogController *)dialog
{
    if (activeNodeDialog)
        [[activeNodeDialog window] close];
    activeNodeDialog = dialog;
    if (activeNodeDialog) {
        [activeNodeDialog setMainWindowController:self];
        NSRect windowRect = [[self window] frame];
        NSRect dialogRect = [[activeNodeDialog window] frame];
        NSPoint pos;
        pos.x = windowRect.origin.x + windowRect.size.width - dialogRect.size.width - 10;
        pos.y = windowRect.origin.y + 32;
        [[activeNodeDialog window] setFrameOrigin:pos];
        [[activeNodeDialog window] makeKeyAndOrderFront:nil];
    }
}

The problem with that is, that the window will "jump" when shown. And that even though I set the position before showing the window with "makeKeyAndOrderFront". The window is a NSPanel *. Anyone any ideas how to fix the jumping?

Setting the position in awakeFromNib is not an option because the main controller is set later.

© Stack Overflow or respective owner

Related posts about cocoa