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.

previous month september 2007 next month
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today