Re: Alternative startup for application
Le 3 avr. 2010 à 05:13, Michael Nickerson a écrit : On Apr 02, 2010, at 10:12 PM, Gideon King wrote: That's the instance method. New in 10.6 is the class method of the same name, which is what I need in this case, since I don't have an event to work with. On 03/04/2010, at 12:09 PM, Klaus Backert wrote: On 3 Apr 2010, at 01:15, Gideon King wrote: Excellent, I like the new way of doing it using NSEvent directly, but I do need to support Leopard. - (NSUInteger)modifierFlags Available in Mac OS X v10.0 and later. You can use CGEventSourceKeyState( kCGEventSourceStateCombinedSessionState, 0x3A ). That function will get the key down state at the time of the call, and 0x3A is the key code for the option key. altDown = (kCGEventFlagMaskAlternate == (CGEventSourceFlagsState(kCGEventSourceStateCombinedSessionState) NSDeviceIndependentModifierFlagsMask)); ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Alternative startup for application
Hi, I would like to have an application I am working on to be able to start up in the normal way from the finder, but also have an alternative startup that users can access in some way, where I will display a panel that most users wouldn't normally want to see. Issues I am having with this are: 1. I'm not sure what keyboard or mouse options could be used for this, since all the character keys change the selection in Finder, and all the normal modifier keys are used for special functions. So first question is how I can differentiate this special mode open from a normal open? 2. If the application is started up in this special way, how would I be able to detect it, seeing as there is no current event to query? ...or is there some other mechanism I could be using instead? Thanks Gideon ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Alternative startup for application
On Apr 2, 2010, at 1:45 AM, Gideon King wrote: 1. I'm not sure what keyboard or mouse options could be used for this, since all the character keys change the selection in Finder, and all the normal modifier keys are used for special functions. So first question is how I can differentiate this special mode open from a normal open? The Option key is the usual thing. iTunes and iPhoto recognize it at startup, for example. 2. If the application is started up in this special way, how would I be able to detect it, seeing as there is no current event to query? I would have said GetKeys(), but it seems to have been deprecated and removed in the eyeblink [read: decade] since I last used Carbon. There must be some modern equivalent for reading the current state of the keyboard? —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Alternative startup for application
On Apr 2, 2010, at 10:30 AM, Jens Alfke wrote: On Apr 2, 2010, at 1:45 AM, Gideon King wrote: 1. I'm not sure what keyboard or mouse options could be used for this, since all the character keys change the selection in Finder, and all the normal modifier keys are used for special functions. So first question is how I can differentiate this special mode open from a normal open? The Option key is the usual thing. iTunes and iPhoto recognize it at startup, for example. 2. If the application is started up in this special way, how would I be able to detect it, seeing as there is no current event to query? I would have said GetKeys(), but it seems to have been deprecated and removed in the eyeblink [read: decade] since I last used Carbon. There must be some modern equivalent for reading the current state of the keyboard? This works in Snow Leopard and Leopard (I believe). - (void)applicationDidFinishLaunching:(NSNotification *)notif { CGEventRef event = CGEventCreate(NULL); CGEventFlags modifiers = CGEventGetFlags(event); CFRelease(event); CGEventFlags flags = (kCGEventFlagMaskAlternate | kCGEventFlagMaskControl); if ((modifiers flags) == flags) [self doSomethingSpecial]; } Ashley ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Alternative startup for application
On Apr 2, 2010, at 08:30, Jens Alfke wrote: I would have said GetKeys(), but it seems to have been deprecated and removed in the eyeblink [read: decade] since I last used Carbon. There must be some modern equivalent for reading the current state of the keyboard? For completeness: The non-deprecated-but-hard-to-find-documentation-for status of GetKeys () was discussed fairly recently in this thread: http://www.cocoabuilder.com/archive/cocoa/281840-high-level-toolkit-is-it-obsolete-or-not.html The modern (Snow Leopard) equivalent for finding the state of the Option key would be +[NSEvent modifierFlags]. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Alternative startup for application
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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Alternative startup for application
On 3 Apr 2010, at 01:15, Gideon King wrote: Excellent, I like the new way of doing it using NSEvent directly, but I do need to support Leopard. - (NSUInteger)modifierFlags Available in Mac OS X v10.0 and later. NSAlternateKeyMask Set if Option or Alternate key is pressed. Available in Mac OS X v10.0 and later. etc. Klaus ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Alternative startup for application
That's the instance method. New in 10.6 is the class method of the same name, which is what I need in this case, since I don't have an event to work with. On 03/04/2010, at 12:09 PM, Klaus Backert wrote: On 3 Apr 2010, at 01:15, Gideon King wrote: Excellent, I like the new way of doing it using NSEvent directly, but I do need to support Leopard. - (NSUInteger)modifierFlags Available in Mac OS X v10.0 and later. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Alternative startup for application
On Apr 02, 2010, at 10:12 PM, Gideon King wrote: That's the instance method. New in 10.6 is the class method of the same name, which is what I need in this case, since I don't have an event to work with. On 03/04/2010, at 12:09 PM, Klaus Backert wrote: On 3 Apr 2010, at 01:15, Gideon King wrote: Excellent, I like the new way of doing it using NSEvent directly, but I do need to support Leopard. - (NSUInteger)modifierFlags Available in Mac OS X v10.0 and later. You can use CGEventSourceKeyState( kCGEventSourceStateCombinedSessionState, 0x3A ). That function will get the key down state at the time of the call, and 0x3A is the key code for the option key. -- Darkshadow (aka Michael Nickerson) http://www.nightproductions.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com