Remove mappingsChanged with a notification. MappingsController no longer needs to...
[enjoyable.git] / NJKeyInputField.h
1 //
2 // NJKeyInputField.h
3 // Enjoyable
4 //
5 // Copyright 2013 Joe Wreschnig.
6 //
7
8 #import <Cocoa/Cocoa.h>
9
10 extern CGKeyCode NJKeyInputFieldEmpty;
11
12 @protocol NJKeyInputFieldDelegate;
13
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.
19
20 + (NSString *)stringForKeyCode:(CGKeyCode)keyCode;
21 // Give the string name for a virtual key code.
22
23 @property (nonatomic, weak) IBOutlet id <NJKeyInputFieldDelegate> keyDelegate;
24
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.
29
30 @property (nonatomic, readonly) BOOL hasKeyCode;
31 // True if any key is active, false otherwise.
32
33 - (void)clear;
34 // Clear the currently active key and call the delegate.
35
36 @end
37
38 @protocol NJKeyInputFieldDelegate <NSObject>
39
40 - (void)keyInputField:(NJKeyInputField *)keyInput
41 didChangeKey:(CGKeyCode)keyCode;
42 - (void)keyInputFieldDidClear:(NJKeyInputField *)keyInput;
43
44 @end
45