Reputation: 1147
I have an NSWindow designed in Interface Builder, and I want this window to be appear programmatically and be given focus. In my case the window appears, allows itself to be configured with titles, but the window stubbornly refuses to take focus, refuses to resize, and refuses to respond to any kind of input, from pressing the button, to moving the vertical slider, to allowing the window to close.
The NSWindowController is defined as follows:
@interface SignTextTab : NSWindowController <NSWindowDelegate>
- (id)processMessage:(id)message messageUuid:(id)messageUuid messageId:(id)messageId;
@end
and is instantiated as follows:
tab = [[SignTextTab alloc] init];
The NSWindowController loads the NIB as follows:
- (id) init
{
return [super initWithWindowNibName:@"SignTextTab" owner:self];
}
and the window is made visible as follows:
self.window.level = NSModalPanelWindowLevel;
[self.window makeKeyAndOrderFront:self];
Querying the status of the NSWindow directly after the calls above leads to this:
NSWindowStyleMask styleMask = self.window.styleMask;
BOOL isKey = self.window.isKeyWindow;
BOOL canKey = self.window.canBecomeKeyWindow;
The variable isKey is NO, because makeKeyAndOrderFront did not appear to do anything. The variable canKey is YES.
The styleMask is as follows:
NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable
The application is a Safari Web Extension.
Many people have asked the question, but none of these have answers that translate into concrete actions relevant in Xcode 13.
The file's owner is configured as follows.
Does anyone know what concrete steps need to be taken to make sure the NSWindow can gain focus, and provide concrete screenshots of what Interface Builder is supposed to look like when it is configured correctly?
Upvotes: 0
Views: 414