Style Mask

Dris

The Benevolent
Howdy,
I'm having a problem with an application I'm writing in Cocoa. I have a window instantiated in Interface Builder that I display as needed. The problem is, I need its style mask to be NSBorderlessWindowMask, but the style mask can only be set when the window is initialized. How can I set the style mask since the window is instantiated in Interface Builder? Thanks for help in advance.
 
I got it figured out! If anyone else needs to do it, it's not too tough. Just subclass NSWindow (or NSPanel, depending on what you want), set your IB window to be that class, and use the following code in its implementation:

Code:
- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag {
    NSWindow *result = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
    return result;
}

This overrides the init function and sets the style mask to NSBorderlessWindowMask. Hope somebody else can benefit from the code.
 
Back
Top