Textfield

  • I have a window with 5 textfield to enter a serial number of 5x5
    characters.
    When I entrer 5 characters in a textfield, I want that the cursor
    goes automatically in the next textfields.
    How can I make this ?
    Thanks

    *-*-*-*-*
    Eric PETITE-mail :
        <epetit91...>
        <turboloto...>

    Site TURBOLOTO™ :
        http://turboloto.free.fr
    *-*-*-*-*
  • > I have a window with 5 textfield to enter a serial number of 5x5
    > characters.
    > When I entrer 5 characters in a textfield, I want that the cursor
    > goes automatically in the next textfields.

      Why not just use one text field and your own NSFormatter to keep it
    formatted?

      Otherwise, you can respond to each field's -textDidChange: ...

    --
    I.S.
  • Long ago I had a Carbon app which did the five-text-fields thing to
    enter serial numbers.
    When I ported it to Cocoa, I changed it to automatically insert
    hyphens in the text as the user typed.
    This was actually a lot easier for several reasons:
    - it looked more like the key displayed in email/on the CD case
    - no need to handle quirky things like "if the user clicks in an
    empty text field on the right and presses delete, where does the
    insertion point go?"
    - the user can use the arrow keys to move around freely in the text
    field
    - the user can click in the middle of a mostly-completed key, start
    typing, and it will "do the right thing" (insert letters, reflowing
    all the hyphens as appropriate)

    Basically, any time the contents of the text field change, all you do
    is:
    - get the string and insertion point location
    - for the next 3 steps, update the insertion point location any time
    you add or remove characters in front of it:
    - remove all the hyphens
    - do any cleanup (capitalize, strip bad characters)
    - reinsert the hyphens
    - finally, replace the string and place the insertion point back into it

    On Dec 2, 2007, at 7:29 AM, I. Savant wrote:

    >> I have a window with 5 textfield to enter a serial number of 5x5
    >> characters.
    >> When I entrer 5 characters in a textfield, I want that the cursor
    >> goes automatically in the next textfields.
    >
    > Why not just use one text field and your own NSFormatter to keep
    > it formatted?
    >
    > Otherwise, you can respond to each field's -textDidChange: ...
    >
    > --
    > I.S.
  • > I have a window with 5 textfield to enter a serial number of 5x5
    > characters.
    > When I entrer 5 characters in a textfield, I want that the cursor
    > goes automatically in the next textfields.
    > How can I make this ?
    > Thanks

    You could implement this delegate method for your text field:

    -(void)controlTextDidChange:(NSNotification *)aNotification {

        id mySenderTextField = [aNotification object];

        if ( [[mySenderTextField stringValue] length] == 5)
    [[mySenderTextField window] makeFirstResponder:[mySenderTextField
    nextValidKeyView]];
    }

    Flofl.
previous month december 2007 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
31            
Go to today