Re: WM_KEYDOWN
Re: WM_KEYDOWN
- Subject: Re: WM_KEYDOWN
- From: John Stiles <email@hidden>
- Date: Wed, 11 Apr 2007 10:33:46 -0700
On Apr 11, 2007, at 10:18 AM, xcocoa wrote:
John,
You might look into
- (void)controlTextDidChange:(NSNotification *)aNotification
I bet this will handle whatever you need. I use this for a text
field that contains a product registration number—we want to make
the formatting match the label on the CD case. So after every
keystroke I filter out bogus characters and add in hyphens where
needed.
Where do you get the keystroke from ?
I really appreciate if you could post a small code sample
thanks,
You can't directly get the "keystroke" with this technique, since it
is called on any control text changes—e.g. if you paste text or drag
text in, that also causes the control text to change. (Also, if you
are using a Japanese/Chinese input method, you will see big changes
all at once because of the way those input methods work.) But of
course, you need to handle all of these cases as well, so just raw
keystrokes are not enough—there are lots of ways to get text into a
control, not just typing one ASCII character at a time.
What you can do is keep tabs on what the control text used to be, and
then look at what it is now, and compare the two to see what changed.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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