November Rain November Rain - 2 months ago 7
Swift Question

Create a fixed position window in Mac Application development

I'm new in Mac Application development. I want to create a small tool which having a small window fixed position at the right bottom of the screen like this picture:

enter image description here

Is it possible to do that?

Answer

It's possible - but I wouldn't recommend it, as it could be a bad user experience.

The solution is simple, though: set the .isMovable property of the window to false.

For example, for a window IBOutlet, setting:

window.isMovable = false

in applicationDidFinishLaunching works well.

You can also, for example, use window.setFrameOrigin(_ point: NSPoint) to first set it at a fixed position.