/* NDHotKeyControl.h Created by Nathan Day on 29.03.08 under a MIT-style license. Copyright (c) 2008 Nathan Day Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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. */ /*! @header NDHotKeyControl.h @abstract Header file for a subclass of NSTextField for getting hot key combinations from the user. @discussion The NDHotKeyControl can be used to get a NDHotKeyEvent for the last key combination pressed by the user. @updated 2010-01-18 */ #import @class NDHotKeyEvent; /*! @class NDHotKeyControl @abstract Subclass of NSTextField for getting hot key combinations from the user. @discussion The NDHotKeyControl can be used to get a NDHotKeyEvent for the last key combination pressed by the user. */ @interface NDHotKeyControl : NSTextField { @private UInt16 keyCode; NSUInteger modifierFlags; BOOL requiresModifierKeys, readyForEvent, stayReadyForEvent; id lastReadyForEventSender; } - (IBAction)readyForHotKeyEventChanged:(id)sender; /*! @method keyCode @abstract Get key code. @discussion Returns the key code for the last key combination the user pressed while the reciever was active. @result A UInt16 containing key code. */ - (UInt16)keyCode; /*! @method keyCharacter @abstract Get unicode character. @discussion Returns the unicode character for the last key combination the user pressed while the reciever was active. @result A unichar containing character. */ - (unichar)keyCharacter; /*! @method modifierFlags @abstract Get modifer flags. @discussion Returns the modifer flags for the last key combination the user pressed while the reciever was active. @result A unsigned long containing modifer flags. */ - (NSUInteger)modifierFlags; /*! @method hotKeyEvent @abstract Get NDHotKeyEvent @discussion Returns the NDHotKeyEvent instance for the last key combination the user pressed while the reciever was active. The NDHotKeyEvent returned will either be one that has already been created or a newly created one otherwise. @result A NDHotKeyEvent for the hot key event. */ - (NDHotKeyEvent *)hotKeyEvent; /*! @method setRequiresModifierKeys: @abstract Set whether hot keys entered need modifiers keys. @discussion This does not include function key which do not require modifier keys no matter what the value you pass for the argument flag @param flag If NO then the reciever only accepts hot keys combination containing modifer keys. */ - (void)setRequiresModifierKeys:(BOOL)flag; /*! @method requiresModifierKeys @abstract Returns whether hot keys entered need modifiers keys. @discussion This does not include key which do not require modifier keys no matter what the value is returned. @result If NO then the reciever only accepts hot keys combination containing modifer keys. */ - (BOOL)requiresModifierKeys; /*! @method setReadyForHotKeyEvent: @abstract Set up the control to accept input @discussion Setting readyForHotKeyEvent to YES will disable all Hot Key Events and then prepare NDHotKeyControl for keyboard input. Setting readyForHotKeyEvent to NO will re-enables all Hot Key Events and then stops NDHotKeyControl for accepting keyboard input. @param flag <#description#> */ - (void)setReadyForHotKeyEvent:(BOOL)flag; /*! @method readyForHotKeyEvent @abstract Is the control set up to accept input @discussion Returns the current state of readyForHotKeyEvent as set by the method setReadyForHotKeyEvent:. */ - (BOOL)readyForHotKeyEvent; /*! @method setStayReadyForEvent: @abstract Will the control remain continually active. @discussion By default NDHotKeyControl will accept one key and then call [self setReadyForHotKeyEvent:NO], setStayReadyForEvent: allows you to change this behaviour so that NDHotKeyControl will continue accepting keys until it is manually deactivated. */ - (void)setStayReadyForEvent:(BOOL)flag; /*! @method stayReadyForEvent @abstract Will the control remain continually active. @discussion By default NDHotKeyControl will accept one key and then call [self setReadyForHotKeyEvent:NO], if stayReadyForEvent returns YES, NDHotKeyControl will continue accepting keys until it is manually deactivated. */ - (BOOL)stayReadyForEvent; @end