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

Cocoa: integrate NSApplication into an existing c++ mainloop

I know, that I am not the first one to try to use Cocoa on OSX together with an existing c/c++ main loop, but I am not really liking the solutions I came across so far so I came up with a different idea I'd like to discuss. The most common way I…
moka
  • 4,353
  • 2
  • 37
  • 63
26
votes
3 answers

How to programmatically make cocoa application active

I've got a background process that makes a transparent window appear when a hotkey is pressed: [window makeKeyAndOrderFront:nil]; [[content animator] setAlphaValue:1.0]; // alpha was 0.0 ... the window shows up fine & in front of the other windows…
Dave Carpeneto
  • 1,042
  • 2
  • 12
  • 23
15
votes
1 answer

Subclass NSApplication in Swift

I created NSApplication subclass: class MyApplication: NSApplication { override func sendEvent(theEvent: NSEvent) { if theEvent.type == NSEventType.KeyUp && (theEvent.modifierFlags & .CommandKeyMask).rawValue != 0 { …
iPera
  • 1,053
  • 1
  • 12
  • 24
14
votes
1 answer

Document sheet not responding to keyboard events

I think it's a first responder problem, but I'm not sure. I'm implementing an edit window for data in a table view. Very similar in concept to the UI for editing filter rules in Mail.app. I have an editing window that I attach to my primary window…
Flyingdiver
  • 2,142
  • 13
  • 18
14
votes
2 answers

NSApplication endSheet: has no effect

Ok, this is really stumping me: I create a modal sheet on a window as -(IBAction) login: (id) sender { [NSApp beginSheet:loginWindow modalForWindow:window modalDelegate:nil didEndSelector:nil contextInfo:nil]; } and try to…
tomwhipple
  • 2,850
  • 27
  • 28
13
votes
4 answers

How to know if a NSWindow is fullscreen in Mac OS X Lion?

I guess I should check if [NSApplication presentationOptions] contains NSFullScreenModeApplicationPresentationOptions, but how do I achieve that? EDIT: using [NSApplication presentationOptions] doesn't work as in my document-based app there might be…
Nickkk
  • 2,261
  • 1
  • 25
  • 34
12
votes
3 answers

Is there a main.swift which is equivalent to the @NSApplicationMain annotation?

Creating a new Cocoa project in XCode gives me an AppDelegate.swift file which looks like this: import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak var window: NSWindow! } The @NSApplicationMain…
jameshfisher
  • 34,029
  • 31
  • 121
  • 167
11
votes
4 answers

NSApplication orderFrontStandardAboutPanel: Making my about panel slightly less standard

What are my options, if any, of adding additional, arbitrary data to the standard Cocoa about dialog that is displayed by an NSApplication when it receives a orderFrontStandardAboutPanel message.
anthony
  • 40,424
  • 5
  • 55
  • 128
11
votes
1 answer

how to get windows of NSRunningApplication

I want to get the window list for a running application. I can get the running application list from [[NSWorkspace sharedWorkspace] runningApplications], but the window list is only available on NSApplication. Is there some way to convert from…
pvinis
  • 4,059
  • 5
  • 39
  • 59
10
votes
1 answer

Get NSWindow from kCGWindowNumber

From kCGWindowNumber, how do I get NSWindow ref. I tried using: [NSApp windowWithWindowNumber:windowNumber] but I always get a null value. I need to get the NSWindow to apply [window setlevel:NSFloatingWindowLevel], that I have set the always on…
Esse
  • 121
  • 1
  • 5
9
votes
2 answers

Is NSApp terminate:id deprecated?

I have been searching for how to terminate my application programmatically. I found in many topics people using NSApp terminate:id. In Xcode terminate:id is crossed. Is this method deprecated ? Should I use it to terminate my application ? If no…
George Sofianos
  • 1,141
  • 1
  • 13
  • 26
8
votes
2 answers

Start Cocoa app without showing the main window

I have a simple Cocoa app with a single NSWindow where I can enter some credentials and after the submission the app starts an another process. In case the credentials were entered once and cached I would like to start the process by running the app…
Don Grem
  • 1,257
  • 3
  • 17
  • 25
8
votes
1 answer

In Apple's Cocoa API, why is it important that NSApplicationMain be called from the main thread?

In the documentation for NSApplicationMain, it says: Creates the application, loads the main nib file from the application’s main bundle, and runs the application. You must call this function from the main thread of your application [...]. The…
Calvin
  • 2,872
  • 2
  • 21
  • 31
8
votes
1 answer

How to get process serial number of current running process

In OS X 10.9 and below, we can get the process serial number of the current running process with: ProcessSerialNumber pen; GetCurrentProcess( &psn ); However, GetCurrentProcess() is now deprecated and I'm unsure how to find a process' serial number…
Lenny
  • 388
  • 3
  • 15
8
votes
3 answers

Cocoa application menu bar not clickable

I'm building a menu bar in my cocoa application with the following code in the @implementation of my custom application CustomApplication: +(void) setUpMenuBar { [CustomApplication sharedApplication]; // Main menu NSMenu* mainMenu = [NSApp…
Théo Winterhalter
  • 4,908
  • 2
  • 18
  • 34
1
2 3
11 12