Limiting Character Input In An NSTextField

  • Does anyone know how to limit the number of characters
    that can be entered into an NSTextField. I have a
    unique situation where only five numbers should be
    entered, and each number should only be a value from 1
    to 5. I tried subclassing NSTextField and using
    KeyDown() to catch each number entered, but the
    KeyDown() method never gets called?!?!

    __________________________________________________
    Do You Yahoo!?
    Tired of spam?  Yahoo! Mail has the best spam protection around
    http://mail.yahoo.com
  • Ian,

    On 26.4.2005, at 23:59, Ian was here wrote:

    > Does anyone know how to limit the number of characters
    > that can be entered into an NSTextField. I have a
    > unique situation where only five numbers should be
    > entered, and each number should only be a value from 1
    > to 5.

    See "NSFormatter".

    > I tried subclassing NSTextField and using
    > KeyDown() to catch each number entered, but the
    > KeyDown() method never gets called?!?!

    That's since NSTextField never edits anything -- see "field editor".
    ---
    Ondra ├łada
    OCSoftware:    <ocs...>              http://www.ocs.cz
    private        <ondra...>            http://www.ocs.cz/oc
previous month april 2005 next month
MTWTFSS
        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