Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

standardWindowButton returns nil #7

Open
UXDart opened this issue Dec 8, 2014 · 3 comments
Open

standardWindowButton returns nil #7

UXDart opened this issue Dec 8, 2014 · 3 comments

Comments

@UXDart
Copy link

UXDart commented Dec 8, 2014

Hi! I'm trying to create a window by code:
self = [super initWithContentRect:rect styleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask backing:NSBackingStoreBuffered defer:NO];

and I got an error saying that it was trying to add nil to an array. I found that the problem is in the line:
_standardButtons = @[[self standardWindowButton:NSWindowCloseButton],
[self standardWindowButton:NSWindowMiniaturizeButton],
[self standardWindowButton:NSWindowZoomButton]];

standardWindowButton: is returning nil for all 3 calls. any idea? I'm on 10.10.1

TIA

@UXDart
Copy link
Author

UXDart commented Dec 8, 2014

I found that calling for example [NSWindow standardWindowButton:NSWindowCloseButton forStyleMask:self.styleMask] fixes it.

HTH

@vojto
Copy link

vojto commented Oct 3, 2016

I ran into the same issue when creating window programmatically.

Explanation (from docs):

class func standardWindowButton(NSWindowButton, for: NSWindowStyleMask)

Returns a new instance of a given standard window button, sized appropriately for a given window style.

func standardWindowButton(NSWindowButton)

Returns the window button of a given window button kind in the window’s view hierarchy.

@weAreYeah Is this repo still maintained? If I submit a PR for this, is anybody going to merge it in?

@vojto
Copy link

vojto commented Oct 3, 2016

Btw. I was only seeing this error when I created window without specifying style masks for all three buttons, i.e.:

self.init(contentRect: rect, styleMask: [.titled], backing: .buffered, defer: false)

Once I added the appropriate style masks, everything works fine:

self.init(contentRect: rect, styleMask: [.titled, .closable, .miniaturizable, .resizable], backing: .buffered, defer: false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants