NSWindow appears under other windows, despite "makeKeyAndOrderFront"

Viewed 82

There are many examples of how to create an NSWindow on S.O. that, when I try them on Catalina, do not quite work. I do see drawRect get called for my view, and the app seems to be waiting for events, but the window shows up under other windows despite my using "makeKeyAndOrderFront". What can cause this?

Has something changed with Catalina?

int main() { 
    NSAutoreleasePool *pool = [[NSAutoreleasePool  alloc] init];
    [NSApplication sharedApplication];
    MyAppDelegate *delegate = [[MyAppDelegate alloc] init];
    NSApp.delegate = delegate;
    [NSApp run];
    [delegate release];
    [pool release];
    return 0; 
}

- (void) applicationDidFinishLaunching: (NSNotification *) notification{
    NSRect frame = NSMakeRect(0, 0, DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT);
    NSWindow *window = [[NSWindow alloc] initWithContentRect: frame
                        styleMask:NSBorderlessWindowMask
                        backing: NSBackingStoreBuffered
                        defer: NO
        ];
    self.window = window;
    self.view = [[MyView alloc] init];
    self.window.contentView = self.view;
    self.window.delegate = self;
    [self.window makeKeyAndOrderFront: nil];
}

In addition, the Dock doesn't show the new window's icon.

0 Answers
Related