Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

fbs419

macrumors newbie
Original poster
Sep 9, 2012
8
0
I had some code to pop up a window at the beginning of my app. I wanted the window to appear in a given place. In awakeFromNib, I had:

CGFloat x, y;
NSRect usableScreenRect = [[NSScreen mainScreen] visibleFrame];
x = usableScreenRect.size.width/5.5;
y = usableScreenRect.size.height;
[myWindow setFrame: NSMakeRect(x,y,300,200) // hard coded #s for now

That worked fine. But I need to run this as a modal window, so right after this code, I added:

[NSApp runModalForWindow:myWindow];

runModalForWindow centers the window by default, but I would like to override that. I have seen some references to runModalWindow:relativeToWindow, and I see that it has been deprecated. I'm not even sure that is what I want.

I just need a simple way to run a modal window, but position it where I want. Is this possible?

Thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.