Loading...

How to open an app's window on top of all others in Swift?

question macOS swift
Ram Patra Published on August 6, 2020
SDK - macOS 10.0+

You can open your app’s window on top of all other open application windows with the below code:

windowController?.showWindow(self)
NSApp.activate(ignoringOtherApps: true)

For example, in my app––Presentify––when you click on ‘Preferences’, the Settings window opens up on top of all other applications. With just windowController?.showWindow(self), the window would open fine, but it won’t be visible to the user if other apps are open.

Presentify

Take your presentation to the next level.

FaceScreen

Put your face and name on your screen.

ToDoBar

Your to-dos on your menu bar.

Ram Patra Published on August 6, 2020
Image placeholder

Keep reading

If this article was helpful, others might be too

question macOS swift March 14, 2021 How to detect Escape key pressed in macOS apps?

Like Delete key, detection of Escape key press is also slightly different than detecting general key presses.

October 17, 2024 Show your screen and your face at the same time on macOS

In today’s world of remote work and digital content creation, engaging your audience has never been more important. Whether you’re giving a presentation, conducting a tutorial, or recording a demo, adding a personal touch can make all the difference. That’s where FaceScreen comes in. This innovative macOS app allows you to open up your camera view in Picture-in-Picture (PiP) mode, enabling you to show both your screen and your face simultaneously.

question macOS swift November 10, 2021 How to detect fn key press in Swift?

You can override the flagsChanged() method of NSViewController and have your code like below to detect fn key press and release in macOS: