Reputation: 1
So I've just started with some mac developing. My first project is to develop a text based calculator which only consist of two components, one NSTextField and one NSTextView. The TextField takes user input and display the answer in the TextView. What I would like is to implement a function where if the TextField is active and the up arrow is pressed the input goes through the command history. I know how to implement the history function but not how to capture the keypress. I've searched and found in Capturing "up" and "down" keys pressed in NSTextField that one way is to implement:
- (BOOL)control:(NSControl *)control textView:(NSTextView *)fieldEditor
doCommandBySelector:(SEL)commandSelector {
The problem is that since I'm quite new to mac development I still don't get how to implement the function?
Upvotes: 0
Views: 195
Reputation:
@interface AppDelgate <NSTextViewDelegate>
@property IBOutlet (nonatomic,strong) NSTextView* myTextView;
@end
@implementation
-(BOOL) applicationDidLaunch(..) {
myTextView.delegate = self;
}
- (void)keyUp:(NSEvent *)theEvent {
//check theEvent.keyCode (125=up arrow)
}
@end
Upvotes: 0