开发者

Setting Position of NSWindow before Display

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 t开发者_如何学编程he 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.


In Interface Builder, is "visible at launch" checked for the window? If so uncheck it and then you won't even need this code [[activeNodeDialog window] close];. Basically if that is checked then the window is automatically shown when the xib is instantiated... which you don't want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜