5 // Copyright 2013 Joe Wreschnig.
8 #import <Cocoa/Cocoa.h>
10 extern const CGKeyCode NJKeyInputFieldEmpty
;
12 @protocol NJKeyInputFieldDelegate
;
14 @interface NJKeyInputField
: NSTextField
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
*)stringForKeyCode
:(CGKeyCode
)keyCode
;
21 // Give the string name for a virtual key code.
23 @
property (nonatomic
, weak
) IBOutlet id
<NJKeyInputFieldDelegate
, NSTextFieldDelegate
> delegate
;
25 @
property (nonatomic
, assign
) CGKeyCode keyCode
;
26 // The currently displayed key code, or NJKeyInputFieldEmpty if no
27 // key is active. Changing this will update the display but not
28 // inform the delegate.
30 @
property (nonatomic
, readonly
) BOOL hasKeyCode
;
31 // True if any key is active, false otherwise.
34 // Clear the currently active key and call the delegate.
38 @protocol NJKeyInputFieldDelegate
<NSObject
>
41 - (void)keyInputField
:(NJKeyInputField
*)keyInput
42 didChangeKey
:(CGKeyCode
)keyCode
;
43 - (void)keyInputFieldDidClear
:(NJKeyInputField
*)keyInput
;