Search code examples
macoscocoanswindowtitlebar

Cocoa NSWindow keep title bar in fullscreen


I would like to know how to keep the title bar (and the buttons) in fullscreen. Basically, it is hidden, and you need to move your cursor to the top to make the title bar visible. But Google Chrome, keep the title bar. Any idea, how to do that?

Update with screenshots :

Chrome in fullscreen

enter image description here

Chrome in fullscreen, with the cursor on top :

enter image description here

in both cases, the buttons are still visible.


Solution

  • What you want to do is not really conform to Apple UI guidelines but the only way to get such behaviour is to hide the default window buttons and to implement them by yourself. Of course this will require to set the appeariance in different modes ( window active/deactiv) and dependent on mouse location.

    To get the window standard buttons too place them at a different location in the content view of the window will not be enough since there will be hidden and displayed in the window title bar during fullscreen mode.

    The action you would use for the close button:

    view.window?.orderOut(self)
    

    for miniaturize

    view.window?.miniaturize(self)
    

    and for fullscreenmode (maximise):

    view.window?.toggleFullScreen(self)
    

    If you have any questions let me know.

    Have a great day