NSTextField keyboard event
NSTextField keyboard event
- Subject: NSTextField keyboard event
- From: "peiyuan" <email@hidden>
- Date: Wed, 5 Mar 2008 18:23:06 +0800
- Importance: Normal
Hi all,
Situation:
I have a window which contains several NSTextField. In these NSTextField, I want that when a user presses a key which is not a number ( 0-9), the active NSTextField will not accept the key input (that is, it does nothing).
What I find on the list:
I find several posts similar to my situation. However, after reading these posts, I got much confused.
1, Some posts said that I should implement the method:
- (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)aSelector;
2, Some posts said that I should inherit from NSWindow or NSTextField and implement the method:
- (void)keydown: ( event *)et;
My Questions:
1. If 1 is right, where should I implement the method ? Inherit from NSWindow? Inherit from NSTextField and use it to replace NSTextField? And How? Could someone show me some examples?
Also, there is no selector like: insertOne:, insertTwo ... etc. How should I know the user is pressing a number key?
2. If 2 is right, how to do it?
I have tried to inherit from NSTextField. The keyDown event is not called when I press any key.
3. Any other methods to achieve?
Thank you.
Pei-Yuan
@KCodes
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden