Re: Yet another newbie....
Re: Yet another newbie....
- Subject: Re: Yet another newbie....
- From: Ondra Cada <email@hidden>
- Date: Tue, 31 Jul 2001 10:12:03 +0200
tonycate,
>
>>>>> email@hidden (t) wrote at Mon, 30 Jul 2001 21:24:16 -0500:
t> - (void)keyDown:(NSEvent *)theEvent
t> {
t> int characterIndex;
t> int charactersInEvent;
t>
t> charactersInEvent = [[theEvent characters] length];
t> for (characterIndex = 0; characterIndex < charactersInEvent;
t> characterIndex++) {
t> if ([[theEvent characters] characterAtIndex:characterIndex] ==
t> 'A')
t> NSLog( @"received" );
t> else
t> NSLog( @"not received" );
t> }
t> }
t>
t> Anyway, I inserted the above code in my controller class and compiled
t> successfully, but when I debug the program. I don't hit the method.
See the NSResponder documentation for a description how the key events are
interpreted. It is kind of complicated.
Anyway, in case you want to catch keys when some textfield is filled (is it
so?), I'd recommend to use the NSControl delegate method cotrolTextDidChange:
(see docs for it).
t> Note: I'm still scratching my head over - (NSString *)characters {},
t> which I think is supposed to return the character of the key press. I
t> just can't conjure up what supposed to go 'tween the brackets.
Ouch? Somewhat I don't understand: "- (NSString *)characters {}" is a
definition of method, which is named "characters" and returns a NSString
object. There should be its implementation between brackets.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc