I need to display an alert message with NSWindow to the current space in dual screen mode. And I am using this code :
[hudWC.window setFrame:hudFrame display:NO];
[hudWC showWindow:nil];
[hudWC.window makeKeyAndOrderFront:self];
[hudWC.window setOrderedIndex:0];
[hudWC.window setCollectionBehavior: NSWindowCollectionBehaviorCanJoinAllSpaces];
But it didn't work. It always display the message to the screen that has a dock. And I have read this page - How to bring NSWindow to front and to the current Space? but could not solve the problem. How can I choose which screen will display the alert message?
====================================================
Now I have solved the problem. I added 'center' function and it worked! I don't know how it works exactly but it did. The code is as following :
[hudWC.window setFrame:hudFrame display:NO];
[hudWC.window center];
[hudWC showWindow:nil];
[hudWC.window makeKeyAndOrderFront:self];
[hudWC.window setOrderedIndex:0];