• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTextField keyboard event
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSTextField keyboard event
      • From: "I. Savant" <email@hidden>
  • Prev by Date: Re: regexkit [Using NSPredicate to parse strings]
  • Next by Date: Re: Triggering GUI login session from daemon? And reboot.
  • Previous by thread: Re: NSOutlineView slow update w Core Data
  • Next by thread: Re: NSTextField keyboard event
  • Index(es):
    • Date
    • Thread