tags:

views:

121

answers:

3

I'm using this code to bring up my window:

[self.window makeKeyAndOrderFront:self];
[self.window setOrderedIndex:0];

But often it will be beneath other windows or displayed in other Space desktop that I last open it in. How do I make it always appear "in front" to the user?

Update I found the answer from previously asked question; make the window show up to the top of other windows: [NSApp activateIgnoringOtherApps:YES];

But how to move the app to the user's current Space?

+2  A: 

To bring your app to the front:

[NSApp activateIgnoringOtherApps:YES];
jtbandes
Thanks! Any idea on bringing the app to the user's current Space?
Seymour Cakes
+3  A: 

Perhaps you want:

  [self.window setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces];

Experiment with the other collection behaviors... I found NSWindowCollectionBehaviorMoveToActiveSpace was a bit buggy in 10.5 but it might be better now.

Nicholas Riley
Thank you very much. This is exactly what I was looking for.
Seymour Cakes
How do I go about learning all these subtle things without asking? At times I feel very lost in Cocoa-land.
Seymour Cakes
I tend to read *all* the release notes when each new OS version comes out. There's a lot of good information in there, and it only takes an hour or two.
Nicholas Riley
Read the more important programming guides and framework references, too. Start with Cocoa Fundamentals Guide and move on from there.
Peter Hosey
+1  A: 

But how to move the app to the user's current Space?

You don't. Spaces hold windows, not applications. (That's why the collectionBehavior property is on NSWindow, not NSApplication.)

Peter Hosey