Using NSWindow's standardWinowButton: Method

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

  1. Blakeasd macrumors 6502a

    Joined:
    Dec 29, 2009
    #1
    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?
     
  2. jiminaus, Aug 14, 2011
    Last edited: Aug 14, 2011

    jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #2
    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

    Joined:
    Dec 29, 2009
    #3
    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!
     

Share This Page