Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Yet another newbie....



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




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.