jump to navigation

Obj-C NSToolBar and Windows created programatically. 21 December 2012

Posted by David Wilson in General.
trackback

I’ve had this compile error out of XCode. Using the internet to solve it wasn’t that helpful.
I’m Using 10.8, compiling for 10.6 and above.
XCode version is 4.6

ERROR: Can’t have a toolbar in a window with as it’s borderview

In my case the Window is Manually created. To remove the error I had to add “NSTitledWindowMask”

Note that the NSWindow class reference says the following.
windowStyleThe window’s style. It can be NSBorderlessWindowMask, or it can contain any of the options described in “Window Style Masks,” combined using the C bitwise OR operator. Borderless windows display none of the usual peripheral elements and are generally useful only for display or caching purposes; you should normally not need to create them. Also, note that a window’s style mask should include NSTitledWindowMask if it includes any of the others.

There’s the code that creates the window – successfully.

unsigned int styleMask = ( NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSUnifiedTitleAndToolbarWindowMask );
prefsWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 350, 200)
styleMask:styleMask
backing:NSBackingStoreBuffered
defer:NO];

Hope this helps someone else.

Thank you to Glenn for his assistance.

– David

Comments»

No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: