-4

How to make it possible to place the buttons slightly below and to the right of a regular window without using (toolbar, navigationSpitView, etc) like in the Chrome or FireFox browsers

enter image description here

the image shows that they have a non-standard indentation, without using the toolbar etc

New contributor
Evgeniy Petrukovich is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

1 Answer 1

2

You can approach it through AppKit. SwiftUI views hosted in a macOS window still sit inside an NSWindow, and you can access that window.

Once you have the NSWindow, call
standardWindowButton(_:) with the appropriate NSWindow.ButtonType to grab the traffic-light button you want to customize.

From there you adjust the underlying NSButton and its NSButtonCell. That gives you control over size, insets, and other layout details. If you need full control over the look or behavior, subclassing NSButtonCell is usually the cleanest path.

Sign up to request clarification or add additional context in comments.

2 Comments

There is a problem that when you resize the window, the buttons go back to their default position, but when you close the window and reopen it, the buttons are in the position that we explicitly set
I was able to solve the problem by saving the original system frame buttons and then applying the offset relative to these original values, rather than relative to the current position, which was recalculated by the system each time.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.