diff options
| author | Dave DeLong | 2012-12-25 10:16:27 -0800 | 
|---|---|---|
| committer | Dave DeLong | 2012-12-25 10:16:27 -0800 | 
| commit | 4ed465f39afdd215a21e2c7b651c4599dccd693a (patch) | |
| tree | 5f7e46fff0ac2636288edd61c62c0ef559f0d0f0 /DDHotKeyCenter.h | |
| parent | 8c2ee2148e6f35674b0b0c7701f0ae306ec230d5 (diff) | |
| download | DDHotKey-4ed465f39afdd215a21e2c7b651c4599dccd693a.tar.bz2 | |
Updates
Made DDHotKeyCenter a true singleton, updated for ARC
Diffstat (limited to 'DDHotKeyCenter.h')
| -rw-r--r-- | DDHotKeyCenter.h | 39 | 
1 files changed, 19 insertions, 20 deletions
| diff --git a/DDHotKeyCenter.h b/DDHotKeyCenter.h index 6274b36..58dc9d2 100644 --- a/DDHotKeyCenter.h +++ b/DDHotKeyCenter.h @@ -1,7 +1,7 @@  /*   DDHotKey -- DDHotKeyCenter.h - Copyright (c) 2010, Dave DeLong <http://www.davedelong.com> + Copyright (c) 2012, Dave DeLong <http://www.davedelong.com>   Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. @@ -10,19 +10,15 @@  #import <Cocoa/Cocoa.h> -#if NS_BLOCKS_AVAILABLE  //a convenient typedef for the required signature of a hotkey block callback  typedef void (^DDHotKeyTask)(NSEvent*); -#endif  @interface DDHotKey : NSObject -@property (nonatomic, readonly, retain) id target; +@property (nonatomic, readonly) id target;  @property (nonatomic, readonly) SEL action; -@property (nonatomic, readonly, retain) id object; -#if NS_BLOCKS_AVAILABLE -@property (nonatomic, readonly, copy) DDHotKeyTask task; -#endif +@property (nonatomic, readonly) id object; +@property (nonatomic, readonly) DDHotKeyTask task;  @property (nonatomic, readonly) unsigned short keyCode;  @property (nonatomic, readonly) NSUInteger modifierFlags; @@ -31,56 +27,59 @@ typedef void (^DDHotKeyTask)(NSEvent*);  #pragma mark - -@interface DDHotKeyCenter : NSObject { +@interface DDHotKeyCenter : NSObject -} ++ (id)sharedHotKeyCenter;  /**   Register a target/action hotkey.   The modifierFlags must be a bitwise OR of NSCommandKeyMask, NSAlternateKeyMask, NSControlKeyMask, or NSShiftKeyMask;   Returns YES if the hotkey was registered; NO otherwise.   */ -- (BOOL) registerHotKeyWithKeyCode:(unsigned short)keyCode modifierFlags:(NSUInteger)flags target:(id)target action:(SEL)action object:(id)object; +- (BOOL)registerHotKeyWithKeyCode:(unsigned short)keyCode modifierFlags:(NSUInteger)flags target:(id)target action:(SEL)action object:(id)object; -#if NS_BLOCKS_AVAILABLE  /**   Register a block callback hotkey.   The modifierFlags must be a bitwise OR of NSCommandKeyMask, NSAlternateKeyMask, NSControlKeyMask, or NSShiftKeyMask;   Returns YES if the hotkey was registered; NO otherwise.   */ -- (BOOL) registerHotKeyWithKeyCode:(unsigned short)keyCode modifierFlags:(NSUInteger)flags task:(DDHotKeyTask)task; -#endif +- (BOOL)registerHotKeyWithKeyCode:(unsigned short)keyCode modifierFlags:(NSUInteger)flags task:(DDHotKeyTask)task;  /**   See if a hotkey exists with the specified keycode and modifier flags.   NOTE: this will only check among hotkeys you have explicitly registered with DDHotKeyCenter. This does not check all globally registered hotkeys.   */ -- (BOOL) hasRegisteredHotKeyWithKeyCode:(unsigned short)keyCode modifierFlags:(NSUInteger)flags; +- (BOOL)hasRegisteredHotKeyWithKeyCode:(unsigned short)keyCode modifierFlags:(NSUInteger)flags;  /**   Unregister a specific hotkey   */ -- (void) unregisterHotKey:(DDHotKey *)hotKey; +- (void)unregisterHotKey:(DDHotKey *)hotKey; + +/** + Unregister all hotkeys + */ +- (void)unregisterAllHotKeys;  /**   Unregister all hotkeys with a specific target   */ -- (void) unregisterHotKeysWithTarget:(id)target; +- (void)unregisterHotKeysWithTarget:(id)target;  /**   Unregister all hotkeys with a specific target and action   */ -- (void) unregisterHotKeysWithTarget:(id)target action:(SEL)action; +- (void)unregisterHotKeysWithTarget:(id)target action:(SEL)action;  /**   Unregister a hotkey with a specific keycode and modifier flags   */ -- (void) unregisterHotKeyWithKeyCode:(unsigned short)keyCode modifierFlags:(NSUInteger)flags; +- (void)unregisterHotKeyWithKeyCode:(unsigned short)keyCode modifierFlags:(NSUInteger)flags;  /**   Returns a set of currently registered hotkeys   **/ -- (NSSet *) registeredHotKeys; +- (NSSet *)registeredHotKeys;  @end | 
