I'm making a small program that has four NSTextField boxes. Each box is related to the others by a formula. Basically, I have it working right now where after you click out of the box, it'll calculate the other boxes just fine (you can enter numbers into any of the boxes).
What I want is the after each key-press, I'd like to call the boxes action to calculate the other boxes. So, the results should happen immediately, not only after clicking out of the box or hitting tab, etc..
I'm still learning ObjC, so, while I've tried to review the docs, they don't seem to apply directly to my issue.
I've defined the following actions:
- (IBAction)boxX1:(id)sender;
- (IBAction)boxY1:(id)sender;
- (IBAction)boxX2:(id)sender;
- (IBAction)boxY2:(id)sender;
For each one, there's some code that calls the calculate function in the right way...
So, the basic question is.. How do I watch keyDown: events, and specifically, know that the keyDown event happened in boxX1 vs. boxY2 and, be able to take the content of the boxes (after the keyDown event) and perform my calculation?
For example, here's the code for boxX2:
- (IBAction)boxY2:(id)sender {
self.boxX2.stringValue = [ARCBrain calculateRatio:self.boxX1.stringValue times:self.boxY2.stringValue dividedBy:self.boxY1.stringValue];
}
I just need to be able to call it after each keypress.. Seems easy enough, no?
Thanks