X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=NJKeyInputField.h;fp=NJKeyInputField.h;h=ad026d3f4f0cb163f936f44d20bf727911fb8e99;hp=0000000000000000000000000000000000000000;hb=4a490c57151dd4ba9cb27cc34a0e33fc68fc4d24;hpb=1700c86669723045bf7abd177ca519f47656e995 diff --git a/NJKeyInputField.h b/NJKeyInputField.h new file mode 100644 index 0000000..ad026d3 --- /dev/null +++ b/NJKeyInputField.h @@ -0,0 +1,45 @@ +// +// NJKeyInputField.h +// Enjoyable +// +// Copyright 2013 Joe Wreschnig. +// + +#import + +extern CGKeyCode NJKeyInputFieldEmpty; + +@protocol NJKeyInputFieldDelegate; + +@interface NJKeyInputField : NSTextField + // An NJKeyInputField is a NSTextField-like widget that receives + // exactly one key press, and displays the name of that key, then + // resigns its first responder status. It can also inform a + // special delegate when its content changes. + ++ (NSString *)stringForKeyCode:(CGKeyCode)keyCode; + // Give the string name for a virtual key code. + +@property (nonatomic, weak) IBOutlet id keyDelegate; + +@property (nonatomic, assign) CGKeyCode keyCode; + // The currently displayed key code, or NJKeyInputFieldEmpty if no + // key is active. Changing this will update the display but not + // inform the delegate. + +@property (nonatomic, readonly) BOOL hasKeyCode; + // True if any key is active, false otherwise. + +- (void)clear; + // Clear the currently active key and call the delegate. + +@end + +@protocol NJKeyInputFieldDelegate + +- (void)keyInputField:(NJKeyInputField *)keyInput + didChangeKey:(CGKeyCode)keyCode; +- (void)keyInputFieldDidClear:(NJKeyInputField *)keyInput; + +@end +