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 cancel, but when I click on the red arrow in the top left of the windows, the application does not quit when the window is closed this way. Is this intended functionality or am I doing something wrong (not setting some flag?). Also, is there some way to disable this button?
applicationShouldTerminateAfterLastWindowClosed: does not seem to work when the red x is used to close my Cocoa app
3.6k Views Asked by Mike2012 At
1
There are 1 best solutions below
Related Questions in COCOA
- In what context can we use an unqualified #selector() expression in Swift?
- How can I trigger macOS system gamepad API based on a value received from iOS app through core bluetooth
- Using sort descriptors in Outline View
- NSTableView to NSOutlineView Drag & Drop not accepting drop
- How to remove horizontal line in bottom of section NSTableView?
- CGSRegionRef: How is an arbitrary region represented as union of rects?
- Listen for Touch Events on MacOS (Trackpad)
- Window "yanks" when moving
- Writing NSFilePromiseProviders to pasteboard blocks app on quit
- Basic ImGui program doesn't render, leaks memory and crashes
- NSTokenField suggestion using context menu in swift
- How to link multiple text views to a single text storage in TextKit 2
- I would like to know why I’m not getting IBOutlets connected in an App’s window
- How to make a custom event loop in Cocoa?
- Why is restoreWindow(withIdentifier:state:) called after applicationDidFinishLaunching(_:)?
Related Questions in MACOS
- Error installing Nativescript on Mac M2 Sonoma 14.4.1
- macOS - Most secure way of a GUI SUDO_ASKPASS
- When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
- Why does Hugo generate different taxonomy-related HTML on different OS's?
- ZSH function parameters conundrum
- how to make read only file/directory in Mac writable
- macOS BigSur - Unable to run bundled php version or brew php 8
- 9 Digit Addresses in Hexadecimal System in MacOS
- MacOS Bash-Script: while read p and echo
- How to make a range for tail rows on a categorized table in Numbers with JXA scripts?
- Cannot build a basic project with curl on Mac (M2) for Raspberry Pi Pico
- How to recover deleted files from create vite react project
- Can't run built SFML project from Xcode template
- React Native - RealmJS - Linker command failed with exit code 1
- How can I manually add a keyboard shortcut to a Shortcut Action Service directly via the system files, without going through the System Prefs GUI?
Related Questions in NSAPPLICATION
- Does an NSApplication require an NSApplicationDelegate?
- Why does calling NSApplication.shared directly ignore the class specified by the Principal class in Info.plist?
- macOS Sonoma: Activate Menubar-Only App When UI Appears
- 'LaunchIsDefaultLaunchKey' key in the Notification parameter in applicationDidFinishLaunching(_ notification: Notification)
- How can I make a sub class of NSApplication and use it for running my app?
- Can I call NSApplicationLoad from a launch daemon?
- Can [NSApplication sharedApplication] ever return nil?
- Running NSApplication.shared alongside Vapor?
- Mac Widgets: NSApplication openURLs not called from widget
- Adding NSMenuItem to NSApp.MainMenu not inserting new menu item
- WidgetKit: deep-link from widget to macOS app
- Are these two snippets equivalent?
- Open Mac OSX app on current desktop when opened in separate desktop
- "NSApp.activate" in front of another app in fullscreen mode
- How to stop() main thread NSApp run() event loop? (embedded in C++)
Related Questions in IKPICTURETAKER
- IKPictureTaker - Set Opening Tab
- How to get IKpictureTaker panel, select the file event
- Application hangs on clicking "Choose" button in IKPictureTaker view
- Disabling ESC and Command . in an OSX Cocoa app
- applicationShouldTerminateAfterLastWindowClosed: does not seem to work when the red x is used to close my Cocoa app
- Qutting a cocoa app after closing a window
- Getting Strange video warning from my IKPictureTaker App
- Making a Cocoa App Pop Up a Widget instead of a Window
- Trouble deciphering java class not visible from class loader error
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Clicking the red button does not close an application, partly because that verb does not go with that noun. The red button closes the window it's on; it does not quit your application. (An application can and will often have multiple windows on Mac OS X.)
That's where
applicationShouldTerminateAfterLastWindowClosed:comes in. Whenever the user closes the last window on the screen (whether by clicking the red button, by choosing Close from the File menu, or by some other means), the NSApplication object will send anapplicationShouldTerminateAfterLastWindowClosed:message to its delegate, to ask it whether the application should terminate. If the delegate responds to the message by returningYES, then the application will terminate itself.You don't say exactly how you're “using”
applicationShouldTerminateAfterLastWindowClosed:. If you're just sending it to some object, that's not going to work, because you're asking a question (“should the application terminate after the last window is closed?”) and then ignoring the answer. If you implement the method in an object, but that object isn't the application's delegate, that won't work either—the application object only sends that message to its delegate.You need to implement the method in your delegate, and return
YESwhen it is appropriate for the application to terminate when the user closes its last window.