How to disable non-roman input in NSTextField
How to disable non-roman input in NSTextField
- Subject: How to disable non-roman input in NSTextField
- From: Jay Bruins <email@hidden>
- Date: Mon, 24 Sep 2007 15:18:28 -0700
- Acceptlanguage: en-US
- Thread-topic: How to disable non-roman input in NSTextField
I have an NSTextField in an installer pane that is supposed to accept a product key. A product key is typical roman alphanumeric string (a-zA-Z0-9). Because the application is used internationally, I would like to force the input method to roman to prevent the user from attempting to enter non-roman (e.g. Katakana) characters.
NSFormatter is insufficient because the text field/formatter do not receive the user's input until after input is fully determined (Katakana and other input methods do not have a 1-to-1 mapping of keystrokes to characters). Users expect to enter roman characters into this field but should not have to change their input source to do so.
It is possible to hack something together to determine when the field has focus, call carbon methods (GetScriptManagerVariable, KeyScript, etc) to save/change the system script, and then restore the script when the field loses focus, but this is messy.
The code is expected to run on 10.4 and later.
Any leads on how best to resolve this would be much appreciated.
J
_______________________________________________
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