Questions tagged [nsapplication]

NSApplication is the central class in Apple's AppKit framework.

The NSApplication class is the central class in Apple's AppKit framework (). It is responsible for starting the main run loop and provides the central framework for your application’s execution.

References:

178 questions
1
vote
0 answers

Recreating NSApplication.Main in monomac

I'm trying to recreate nsapplication.main in my app. I want to make my app do a number of things my way rather than automatically doing things I don't want. I guess I'm a code control freak. Sadly, NSEvent E is always null, what am I missing? Thanks…
Gordon Truslove
  • 724
  • 2
  • 10
  • 19
1
vote
1 answer

How to know if the user force quit app?

In my mac application I am supporting full screen by changing system resolution of the device. And I am resetting back to old resolution if the user switches from full screen to windowed mode or if user quits the app and I need to handle force quit…
Chandan Shetty SP
  • 5,087
  • 6
  • 42
  • 63
1
vote
1 answer

modal window not closing

I am running a custom NSWindowController as modal window. First I show it like this: ProgressWindow *pWin = [[ProgressWindow alloc] initWithWindowNibName:@"ProgressWindow" andXmlContent:nil]; [NSApp runModalForWindow:[pWin window]]; And…
Daniel
  • 20,420
  • 10
  • 92
  • 149
1
vote
2 answers

NSApplicationSupportDirectory invalid CFStringRef

I'm trying to store a file in the NSApplicationSupportDirectory, since i have a preloaded folder in my app, which i want to add files to once the app have been initialized. I'm trying to NSLog the content of the file, so i can see if it actually…
Niels Sønderbæk
  • 3,487
  • 4
  • 30
  • 43
0
votes
1 answer

Relaunching an already launched application

I have created an application for Mac OS X, and I have a desktop shortcut for it (created using ln -s). Now I want to add a feature such that whenever this shortcut is double clicked, with the application already running, some action should be…
ping localhost
  • 479
  • 3
  • 22
0
votes
0 answers

applicationDidFinishLaunching and applicationShouldTerminate

I have a Cocoa App (fairly complicated with OpenGL calls and external IO and serial line ...). A while back I made some modifications and now my applicationDidFinishLaunching is not called anymore! So far I couldn't find out way (I have my project…
Ali
  • 18,665
  • 21
  • 103
  • 138
0
votes
1 answer

NSApplicationPresentationOptions doesn't work with FIREBREATH

I am trying to customize user experience from the plugin I am working on, my goal is to provide a kiosk style using the options available in COCOA NSApplication, the code is like following: // Hide the dock tile and the menu…
willyMon
  • 612
  • 8
  • 19
0
votes
1 answer

Creating status item - icon shows up, menu doesn't

In a document-based project I am trying to create a status menu. I have a singleton class that builds the status bar, and I am initiating it from an application delegate, as you can see. When I run this, I get no errors, but only an image of the…
janeh
  • 3,734
  • 7
  • 26
  • 43
0
votes
1 answer

How can I make a sub class of NSApplication and use it for running my app?

I am trying to make sub class of NSApplication with this code: class MySubNSApplication: NSApplication { static var internalShared: MySubNSApplication = MySubNSApplication() static override var shared: MySubNSApplication { …
ios coder
  • 1
  • 4
  • 31
  • 91
0
votes
0 answers

How to toggle menu bar popover from a method outside of AppDelegate in Swift?

I am new to Swift UI and currently working on a menu bar app for MacOS. I created a AppDelegate in which there is a method which toggles the menu bar popover when the icon in the menu bar is clicked - This is all working perfectly. Now I want to use…
0
votes
1 answer

Can I call NSApplicationLoad from a launch daemon?

To receive some notifications (for instance, CGDisplayRegisterReconfigurationCallback) from my launch daemon (written in C++ for macOS) I need to call NSApplicationLoad before I call CFRunLoopRun(); (as described here). But once in a while my daemon…
c00000fd
  • 20,994
  • 29
  • 177
  • 400
0
votes
1 answer

Running NSApplication.shared alongside Vapor?

I want my Vapor app to be able to create and show NSWindows on the host machine. For this I've edited main.swift like this: import AppKit import App import Vapor var env = try Environment.detect() try LoggingSystem.bootstrap(from: &env) let app =…
0
votes
0 answers

WidgetKit: deep-link from widget to macOS app

I am adopting my iOS widget to my Mac app, and one thing I can't figure out is when I do a deep-link from the widget to the Mac app, where would that get detected? On iOS, it calls: - (BOOL)application:(UIApplication *)application openURL:(NSURL…
Z S
  • 7,039
  • 12
  • 53
  • 105
0
votes
1 answer

Are these two snippets equivalent?

Are both of this snippets the same? Is it possible that on the first one myClass can at some point in the lifetime of the application will be eliminated? @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { private let myClass…
Santiago Alvarez
  • 167
  • 1
  • 12
0
votes
2 answers

"NSApp.activate" in front of another app in fullscreen mode

You can use following code to bring your app window to focus when a specific event was triggered, e.g. a global hotkey was pressed or a tea timer has expired: NSApp.activate(ignoringOtherApps:…
user688262
  • 171
  • 11