Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


Implementing applicationShouldTerminateWhenLa

  • mox

    I want my application to terminate when my "last" window is closed.

    Actually it's a one window application and I don't want it to work in "Document mode" like every applications.

    I'm currently working on a SSH Front End (similar to Putty / SecureCRT) for OS X

    Here is a screenshot of a pre-beta

    Once I finish the "Connections" window and that everything works I will put it on

    If anyone wants to see the source or wants to help me I can be contacted on msn or email at


    • mox

      Ok.. looks like I found the answer by myself.. after ~3-4 days of searching.. lol

      1) Open the .pm with your project name.. (, not
      2) add "applicationShouldTerminateAfterLastWindowClosed" in the properties of your ProjectName class
      3) create the following sub:
      sub applicationShouldTerminateAfterLastWindowClosed : Selector(applicationShouldTerminateAfterLastWindowClosed:) ArgTypes(@) ReturnTypes(v) {
        my ($self) = @_;

      Et voila ! :)

    • Sherm Pendley
      Sherm Pendley

      Ouch. No, that is *not* what this delegate method is for. Like all delegate methods with names like fooShouldBar, the idea here is to give the delegate "veto power" to either allow Bar to proceed, or not. The correct return value (as is clearly stated in the Cocoa docs...) is a BOOL (c), not void (v).

      You return TRUE (i.e. 1 from Perl) if the app should be allowed to terminate, and 0 if not.