• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Alternative startup for application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alternative startup for application


  • Subject: Re: Alternative startup for application
  • From: Gideon King <email@hidden>
  • Date: Sat, 3 Apr 2010 09:15:22 +1000

Excellent, I like the new way of doing it using NSEvent directly, but I do need to support Leopard.

If you launch from Finder holding the Option key, Finder closes the window you launched from, but I can tell people to put it in the dock and launch from there to avoid that.

Here's what I'm doing, which appears to work fine (haven't tested on Leopard yet, but have tested the CG code in Snow Leopard and that worked).:

- (void)applicationWillFinishLaunching:(NSNotification*)aNotification {
	if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) {
		if (([NSEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask) == NSAlternateKeyMask) {
			[self doSpecialStartup];
		}
	} else {
		CGEventRef event = CGEventCreate(NULL);
		CGEventFlags modifiers = CGEventGetFlags(event);
		CFRelease(event);

		if ((modifiers & kCGEventFlagMaskAlternate) == kCGEventFlagMaskAlternate) {
			[self doSpecialStartup];
		}
	}
	...
}

Thanks again for the help.

Gideon

> The "modern" (Snow Leopard) equivalent for finding the state of the Option key would be +[NSEvent modifierFlags].

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Alternative startup for application
      • From: Klaus Backert <email@hidden>
References: 
 >Alternative startup for application (From: Gideon King <email@hidden>)
 >Re: Alternative startup for application (From: Jens Alfke <email@hidden>)
 >Re: Alternative startup for application (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: How to save and restore NSScrollView scroll position?
  • Next by Date: Re: Creating WebView in code
  • Previous by thread: Re: Alternative startup for application
  • Next by thread: Re: Alternative startup for application
  • Index(es):
    • Date
    • Thread