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

Minimize all window in mac but every time one window is active

I have added a code to minimize all the running application on NSStatusItem, its a very simple code [[NSWorkspace sharedWorkspace] hideOtherApplications]; But when i run this application then one application is always on the desktop the one with…
Radix
  • 3,639
  • 3
  • 31
  • 47
3
votes
4 answers

How to connect a menu item to a custom action defined in the NSApplication delegate across nib files?

In my Cocoa app I have two NIB/XIB files that I need to connect: MainMenu.xib: contains a custom object for the NSApplication delegate object and connects it to the proper outlet in the NSApplication placeholder. ContextMenu.xib: sets up an NSMenu;…
Mark
  • 6,647
  • 1
  • 45
  • 88
3
votes
1 answer

Open Mac OSX app on current desktop when opened in separate desktop

I'm trying to get a mac app to open on the current desktop when I use a a global keyboard shortcut (that I've overriden manually in the app). However, when I perform the keyboard shortcut, my desktop switches and shows me the app on the desktop it…
Shekar
  • 240
  • 1
  • 5
  • 14
3
votes
1 answer

applicationShouldTerminate called unexpectedly in macOS Swift app

Many people appear to have a problem where their AppDelegate's applicationShouldTerminate is never called. I have the opposite problem! Often (at a guess 20% of the time) when I come back to my Mac in the morning, I discover that something caused my…
jeff-h
  • 2,184
  • 1
  • 22
  • 33
3
votes
2 answers

Quit application after last window closes

I want to close my application when the last main window closes. I cannot use applicationShouldTerminateAfterLastWindowClosed: for the following reasons: 1. Before showing the main window, one confirmation window is displayed and when this window is…
Raviprakash
  • 2,410
  • 6
  • 34
  • 56
3
votes
1 answer

How to implement custom NSApplication terminate: behavior in Cocoa?

I'm attempting to implement custom termination behavior in a Cocoa application. Normally when my application exits gracefully, it performs final-runtime database cleanup and then exits. This occurs inside AppDelegate (delegate of NSApplication)…
Dave
  • 12,408
  • 12
  • 64
  • 67
3
votes
2 answers

Sending replyToApplicationShouldTerminate to NSApplication in Swift

Here is my AppDelegate.swift. I implement the applicationShouldTerminate protocol from NSApplication. Which answer I give depends on the status of is.Started in the mainWindowController. (This is the SpeakLine example from Cocoa Programming for OS…
stormj
  • 43
  • 5
3
votes
0 answers

OS X: capture events when NSApplication is *not* active

How can an app capture events when it is not active? I'm finding that NSApplication doesn't dispatch events unless it's the currently active application (for instance, using nextEventMatchingMask:untilDate:inMode:dequeue:) However, it must be…
Steveo
  • 2,238
  • 1
  • 21
  • 34
3
votes
1 answer

Crash on Application Quit

Can any one help me in resolving this crash. This happens when the App is quit but not always. Application Specific Information: objc_msgSend() selector name: respondsToSelector: Performing @selector(terminate:) from sender NSMenuItem…
3
votes
1 answer

Cocoa application hides on deactivate

If i switch my NSDocument based app to another app, or switch the space, my app hides... Cannot figure out what causes this behavior... Note that Hides on deactivate is set to NO in the main window
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179
3
votes
1 answer

What's the correct way to reopen a window on OSX?

I've got an app that I've created in Xcode. It's not document based. How do I make it so that when the user clicks on say, the dock icon, the window reopens? I'm creating everything out the nib that Xcode automagically gave me. I've tried to…
Moshe
  • 57,511
  • 78
  • 272
  • 425
3
votes
2 answers

Changing NSApplicationIcon across a running application?

I'd like to adjust the NSApplicationIcon image that gets shown automatically in all alerts to be something different than what is in the app bundle. I know that it's possible to set the dock icon with [NSApplication setApplicationIconImage:] -- but…
danwood
  • 1,512
  • 1
  • 10
  • 27
3
votes
1 answer

How to automatically create new NSDocument if no documents are restored?

EDIT: It seems like the issue below only occurs (rather, fails to occur... :) when I run the from within Xcode (I'm on 4.4), rather than from Finder. Is this an Xcode bug, or am I missing something? I want to create a new (untitled) NSDocument when…
3
votes
2 answers

Show NSWindow from separate nib (not modal)

How to do it? I simply want to load a window and show it in front of the main window. NSWindowController* controller = [[NSWindowController alloc] initWithWindowNibName: @"MyWindow"]; NSWindow* myWindow = [controller window]; [myWindow…
brigadir
  • 6,874
  • 6
  • 46
  • 81
2
votes
1 answer

Positioning a Sheet after using beginSheet:modalForWindow:?

I want to display a window as a sheet, which is perfectly running with the following code: [NSApp beginSheet:mySheet modalForWindow:myWindow modalDelegate:nil didEndSelector:NULL contextInfo:NULL]; However, there is ONE LITTLE…
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223