2

I am making an application that can set a running application window to float above other apps so that if you click outside of the app's window, its window will still remain on the screen.

I have tried to use app.activate(options: NSApplication.ActivationOptions.activateIgnoringOtherApps) where app is the frontmost running application set by app = NSWorkspace.shared.frontmostApplication, but this method only shows the window and when you click outside the app it hides again.

func setAppFloating() {
        let app = NSWorkspace.shared.frontmostApplication
        app?.activate(options: NSApplication.ActivationOptions.activateIgnoringOtherApps)
    }

I want to set the window of the running application to Floating so that when you click outside the window, the app should still remain visible above other apps.

  • Are you trying to make the windows or your own app float? Or the windows of some different app? For the former, you can override the `isFloatingPanel` property in your window subclass to return true. – Ken Thomases Apr 28 '19 at 02:30
  • 1
    @KenThomases I want to set the windows of a different app to float. I knew about the floating panel property for my own app. Can you access another app's properties and modify them? Thanks for your answer! – Lucian Boiangiu Apr 28 '19 at 21:34
  • I'm not aware of any way to do that. The AppleScript Standard Suite has a `floating` property for windows, but it's read-only. The Accessibility API reports floating-ness as a sub-role, which is not a writable attribute. There might be private Window-server functions that can do that. – Ken Thomases Apr 28 '19 at 23:12

0 Answers0