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
2
votes
1 answer

Fullscreen app in OS X with multiple windows?

I want to make a fullscreen app that shows the background of the new space, in addition to having normal window behavior. Basically, when the user goes full screen, I want every NSWindow in the app to stay the same size, stay in the same position of…
Justin
  • 2,122
  • 3
  • 27
  • 47
2
votes
1 answer

Cocoa NSApplication not active but receiving mouse events

I'm having a weird issue where I click away from my window. It resigns main and key. Then I click back to it and the view that was clicked on does not respond to the mouse click. But the second click does cause the view to respond. As if during…
Larvell Jones
  • 159
  • 2
  • 15
2
votes
1 answer

Aren't I allowed to override -sendEvent: in my NSApplication subclass?

In my mac os x app, I subclass NSApplication and override it's -sendEvent: method. Apple complains : The app includes 'OBJC_IVAR_$_NSApplication._delegate' from the framework '/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit'. What…
Fatso
  • 1,278
  • 16
  • 46
2
votes
2 answers

Creating NSApplication in cocoa?

I've been searching for quite a while now but simply can't find anything, I already have window which I can create, but now when I tried to call makeKeyAndOrderFront for it, there was no application to call it for, so I was wondering if anyone could…
user1632861
2
votes
1 answer

How to know if my macOS app is in background or in foreground?

I would like to know with Swift, if my macOS app is running in the background of in foreground. I found different ways (for example here: Is there any way to check if iOS app is in background? ) related to iOS apps, but not for modern macOS. It…
Cue
  • 2,952
  • 3
  • 33
  • 54
2
votes
2 answers

How to check "Copied text is from which Application"?

Recently, I am working on an application based on Pasteboard. I want to find out that copied text is not stored in pasteboard from the selected running application. Anyone have idea?
2
votes
1 answer

Mac launch daemon runtime never calls app delegate when starting during reboot

I'm working on a Mac OS X service that is managed as a launch daemon. It does not have any GUI, but it is structured as a Cocoa app run with NSApplicationMain. It seems like even though there is no GUI, there is a problem - everything works fine…
Corbell
  • 1,283
  • 8
  • 15
2
votes
1 answer

Cocoa: Call App Delegate Method from another Class

I'm currently trying to get the path of a file from a drag and drop operation inside of a custom view, and then pass that path to my app delegate. I'm currently using the following: - (BOOL)performDragOperation:(id )sender { …
minimalpop
  • 6,997
  • 13
  • 68
  • 80
2
votes
0 answers

Swift: How to exit a macOS app with an exit code

I use a .app to bundle my command line tool (I use a framework). To quit the app, I use NSapp.terminate(self) and catch it: func applicationWillTerminate(_ aNotification: Notification) { if exitSuccessful { print("successful") }…
Francois T.
  • 430
  • 1
  • 5
  • 9
2
votes
1 answer

why does NSApplication sharedApplication mainMenu return nil?

Apple's docs say: All of an application’s menus in the menu bar are owned by one NSMenu instance that’s created by the application when it starts up. You can retrieve this main menu with the NSApplication method mainMenu. I have the following…
dev4life
  • 10,785
  • 6
  • 60
  • 73
2
votes
1 answer

Why is applicationDidFinishLaunching not being called?

Today Apple came with a new Swift (again). After endless syntax changes I managed to compile (I needed to get rid of xcstate as well as it kept throwing nonsense error messages). But now my applicationDidFinishLaunching is no longer being called.
qwerty_so
  • 35,448
  • 8
  • 62
  • 86
2
votes
0 answers

Why is the menu bar not visible after returning from NSApplicationActivationPolicy.Accessory?

When the application is hidden at launch using: NSApplication.sharedApplication().setActivationPolicy(NSApplicationActivationPolicy.Accessory) It makes sense that the menu bar is not showing when the application is active. Since it doesn't have a…
Mark
  • 16,906
  • 20
  • 84
  • 117
2
votes
1 answer

how to prevent storyboard from opening a window

I am writing a simple application that loads into the status bar and when clicked it opens a popover under the status bar icon. I am using storyboards to define the UI I like to show in my popover. The thing is as soon as I instantiate the…
Farzad
  • 1,132
  • 9
  • 21
2
votes
1 answer

Order of NSApplication delegate calls

I'm noticing something strange in my NSApplication delegate callbacks. When I start the app with debugger attached, I see what I expect: applicationDidFinishLaunching: is called first, then applicationDidBecomeActive: When I run the app without the…
Z S
  • 7,039
  • 12
  • 53
  • 105
2
votes
1 answer

Cocoa NSApp launch automatically after startup / user login

How to create an Helper NSApp that launches after user login? Doesn't have to be AppStore proof...
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179