5 // Copyright 2013 Joe Wreschnig.
8 #import <Cocoa/Cocoa.h>
10 extern const CGKeyCode NJKeyInputFieldEmpty
;
12 @protocol NJKeyInputFieldDelegate
;
14 @interface NJKeyInputField
: NSControl
15 // An NJKeyInputField is a NSTextField-like widget that receives
16 // exactly one key press, and displays the name of that key, then
17 // resigns its first responder status. It can also inform a
18 // special delegate when its content changes.
20 + (NSString
*)displayNameForKeyCode
:(CGKeyCode
)keyCode
;
22 @
property (nonatomic
, weak
) IBOutlet id
<NJKeyInputFieldDelegate
> delegate
;
24 @
property (nonatomic
, assign
) CGKeyCode keyCode
;
25 // The currently displayed key code, or NJKeyInputFieldEmpty if no
26 // key is active. Changing this will update the display but not
27 // inform the delegate.
29 @
property (nonatomic
, readonly
) BOOL hasKeyCode
;
30 // YES if any key is set, NO otherwise.
33 // Clear the currently active key and call the delegate.
37 @protocol NJKeyInputFieldDelegate
39 - (void)keyInputField
:(NJKeyInputField
*)keyInput
40 didChangeKey
:(CGKeyCode
)keyCode
;
41 - (void)keyInputFieldDidClear
:(NJKeyInputField
*)keyInput
;