Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Blakeasd

macrumors 6502a
Original poster
Dec 29, 2009
643
0
Hello,
I am having some trouble using NSWindow's standardWindowButton: method.
This is what I have done:
I added three buttons to my window and created outlets for them. In awakeFromNib I did this:

Code:
 closeButton = [NSWindow standardWindowButton:NSWindowCloseButton forStyleMask:NSBorderlessWindowMask];
    minButton = [NSWindow standardWindowButton:NSWindowMiniaturizeButton forStyleMask:NSBorderlessWindowMask];
    maxButton = [NSWindow standardWindowButton:NSWindowZoomButton forStyleMask:NSBorderlessWindowMask];

To my knowledge this method changes the appearance of the buttons to look like the standard window button, (I'm not sure about this). Then I control-dragged from each button to the window and selected the actions:
performClose:
performMiniaturize:
performZoom:
The buttons work -- they close the window and min/max it, but they still look like buttons I dragged out of the IB Palette. Does this method actually change the appearance of the buttons?
 
No it doesn't change the appearance of the buttons. It gives you new buttons.

It doesn't make sense to put in placeholder buttons and connect them up, because you'll just have to remove and discard them.

You'll need to add the new buttons your window after you get them. You'll also need to connect them up, in code.

Also you might want to be prepared for these buttons having zero size. I've not tested this, but it would make sense that buttons for window style NSBorderlessWindowMask would have zero size. It would make more sense to use a style mask that matches the kind of window you would have if you weren't drawing it yourself.
 
Last edited:
So do I create three NSButtons (not outlets) and set their values like I did before, then I just add the buttons programmatically? I am not sure about the border mask so I just put that, I need a window without a titlebar.
Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.