nsapplication

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 this only affects the dock, and nothing else. I'm able to work around this issue some of...

Click-through buttons and not raising the window

The iTunes mini-player (to give just one example) supports click-through where the application isn't brought to the front when the play/pause and volume controls are used. How is this done? I've been looking through Apple's documentation and have a little to go on, in Cocoa Event-Handling Guide, Event Dispatch it states: Some even...

applicationShouldTerminateAfterLastWindowClosed: does not seem to work when the red x is used to close my Cocoa app

I have a small OSX Cocoa app that just bring up an IKPicutreTaker and saves the picture to a file if one is set. I use applicationShouldTerminateAfterLastWindowClosed: to close the application when the pictureTaker is closed. This all works fine when I either set(this is done when you have picked the picture you want) or when you hit c...

Deactivate agent app after launch in Cocoa

What method should be called to deactivate an app right after it's launch in applicationDidFinishLaunching: delegate method has been called? Or maybe there is a better place to do that? The documentation for deactivate method for NSApplication says that I shouldn't call this method directly since AppKit knows better how to deactivate stu...

How to programmatically make cocoa application active

Hi all - 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 (as I want it to), however until I manually click the window whatever applicati...

iPhone applicationDidFinishLaunching called once in simulator

I put an NSLog statement inside my applicationDidFinishLaunching method. I build and run and see the log output. Then if I hit the home button (in the simulator) and restart the app, I don't see the log output. Why? ...

Disabling/enabling an application menu item

In trying to learn the very fundamentals of menu handling. My test app's menubar has 3 menus -- namely "TestApp", "File" and "Help". I find I can remove these menus entirely, simply by calling say: NSMenu* rootMenu = [NSApp mainMenu]; [rootMenu removeItemAtIndex:2]; However, I'd only ever want to temporarily disable them (gray them ou...

Cocoa: int main function

I'm curious, what role does the int main function play in a Cocoa program? Virtually all of the sample code I've been looking at has only the following code in main.m: #import <Cocoa/Cocoa.h> int main(int argc, char *argv[]) { return NSApplicationMain(argc, (const char **) argv); } What exactly is this doing, and where does t...

How would I develop something like DeskLock from Deskshade?

Hi everyone! Sorry to be a nuisance, but I have yet ANOTHER question. How would I do something like DeskLock from macrabbit's Deskshade app? I've made the little window and that's as far as I've come. I know how to "lock" the screen in 10.6 with PresentationOptions, but I don't want to risk it because last time it wouldn't let me back in...

Cocoa: NSApp beginSheet sets the application delegate?

I am trying to display a custom sheet in my application, but I think I am doing something wrong. While everything seems to be working just fine, I have a rather odd side-effect. (which took hours to figure out). It turns out that everytime I display a sheet in my application, the Application delegate gets set to the instance of the sheet...

Any good way to set the exit status of a Cocoa application?

I have a Cocoa app which interacts with a server and displays a GUI. If there is a fatal error, I display an alert and exit. I'd like to set the exit status to a non-zero value to reflect that an error occurred, for ease of interaction with some other UNIX based tools. Unfortunately I've been unable to find a good way to do so - NSAppli...

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. ...

how to terminate cocoa app in applicationWillFinishLaunching delegate

I have to show the custom license Agreement dialog to the user before they start using my application.So, i have added new window in my mainMenu.xib and showing that window modally using [NSApp runModalForWindow:licenseWindow]; in applicationWillFinishLaunching: delegate by making my main window hidden using visible at Launch to unch...

NSApplication Exception crash

Hi , my xcode iphone / ipad app crashes when it hits main() upon calling NSApplicationMain() only in ipad build not iphone build any help any one!!! ...

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) whenever [NSApp terminate:aSender] is called: - (NSApplicationTerminateReply)applicationShoul...

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 remove it with -(IBAction) loginWindowCancelPressed: (id) sender { debugLog(@"cancel")...

Dragging Files to NSStatusItem

I was told that the application:openFile: delegate method for NSApp would allow my application to open files by dropping them into the dock, but does this also apply to NSStatusItems in the menu bar? I would like to know before trying to implement. ...

NSApplication resigning front most application status: hide v. deactivate

Hi, I've got an application that needs to become the front most application after a timer expires and resign the front most status when the timer is started by pressing a button, e.g. click "start timer" -> app resigns front most application timer expires -> app becomes front most application I deliberately paraphrased things a litt...

What does NSApp hide: actually do with the NSWindow instances?

Hi, I'm working on an NSWindow subclass and I'm running into some strange behavior that makes me question some of my assumptions about how windows work on Mac OS X. What precisely happens to NSWindow instances when [[NSApplication sharedApplication] hide: self] is called? All windows that do not return NO to -(BOOL)canHide disappear f...