-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5b1e45b
Showing
139 changed files
with
20,127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
DDHotKey -- DDHotKeyCenter.h | ||
Copyright (c) 2010, 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. | ||
The software is provided "as is", without warranty of any kind, including all implied warranties of merchantability and fitness. In no event shall the author(s) or copyright holder(s) be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. | ||
*/ | ||
|
||
#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) SEL action; | ||
@property (nonatomic, readonly, retain) id object; | ||
#if NS_BLOCKS_AVAILABLE | ||
@property (nonatomic, readonly, copy) DDHotKeyTask task; | ||
#endif | ||
|
||
@property (nonatomic, readonly) unsigned short keyCode; | ||
@property (nonatomic, readonly) NSUInteger modifierFlags; | ||
|
||
@end | ||
|
||
#pragma mark - | ||
|
||
@interface DDHotKeyCenter : NSObject { | ||
|
||
} | ||
|
||
/** | ||
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; | ||
|
||
#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 | ||
|
||
/** | ||
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; | ||
|
||
/** | ||
Unregister a specific hotkey | ||
*/ | ||
- (void) unregisterHotKey:(DDHotKey *)hotKey; | ||
|
||
/** | ||
Unregister all hotkeys with a specific target | ||
*/ | ||
- (void) unregisterHotKeysWithTarget:(id)target; | ||
|
||
/** | ||
Unregister all hotkeys with a specific target and 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; | ||
|
||
/** | ||
Returns a set of currently registered hotkeys | ||
**/ | ||
- (NSSet *) registeredHotKeys; | ||
|
||
@end | ||
|
Oops, something went wrong.