Using NSWindow's standardWinowButton: Method

Discussion in 'Mac Programming' started by Blakeasd, Aug 14, 2011.

  1. Blakeasd macrumors 6502a

    Dec 29, 2009
    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:

     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:
    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?
  2. jiminaus, Aug 14, 2011
    Last edited: Aug 14, 2011

    jiminaus macrumors 65816


    Dec 16, 2010
    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.
  3. Blakeasd thread starter macrumors 6502a

    Dec 29, 2009
    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.

Share This Page