Glimmr Form Fields

version 1/101201 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Handling field input
    [The handling field input activity runs during the accepting field input action. We can test whether we are receiving field input anywhere else in our code by checking the status of this activity.]

    Handling field input is an activity.

    The queued field is a g-element variable.[The queued field is set when we request to move to a new field, whether by clicking on that field or by typing enter or another termination key during field input.]

    The field input interrupted is a truth state variable. Field input interrupted is false.[The field input interrupted flag is set to true when we want to restart the entire field-input process, but without completing the accepting field input action—basically, when we've moved to another field via "tabbing" (e.g., the enter key)]

    Carry out accepting field input:
        set JUMP POINT FieldInput;[we can test whether we arrived here by jumping using the "field input interrupted" flag, at least up until it's reset right before beginning the handling field input activity.]
        now field-input mode is true;
        if the current field is form input:
            follow the input interpretation rules for the current field;[we interpret input anytime a field is clicked on or "tabbed" away from.]
        if the current field is not the queued field and the current field is form input and keystroke-code terminates input:
            remove focus from the current field;[this also runs the input defocusing rules, a hook for authors]
        now the current field is the queued field;
        follow the field focusing rules for the current field;[hook for authors]
        follow the window-drawing rules for the assigned window of the current field;
        now field input interrupted is false;
        begin the handling field input activity;
        if handling the handling field input activity:
            now the cursor of the input-stream of the current field is the number of characters in the text-string of the input-stream of the current field;
            follow the window-drawing rules for the assigned window of the current field;
            while field-input mode is true:
                #if utilizing Glimmr debugging;
                say "[>console][FFs]Accepting keystroke input for input field [i][current field][/i] (displayed in [assigned window of the current field]). Cursor placed at position [cursor of the input-stream of the current field].[<]";
                #end if;
                process field char input loop;
                [now keystroke is the character code returned;]
                #if utilizing Glimmr debugging;
                say "[>console]Character code entered: [keystroke-code]; text-string of field: [text-string of the input-stream of the current field] (note that this character will not be added to the text-string until it has been checked by the 'for keypress-to-string conversion' rulebook).[<]";
                #end if;
                if keystroke-code is the null char and the queued field is not the current field:[The player clicked on a field rather than enter a keystroke]
                    break;
                if keystroke-code is the null char:[field input was interrupted, we must abort]
                    remove focus from the current field;
                    follow the window-drawing rules for the assigned window of the current field;
                    now field-input mode is false;
                    break;
                follow the keypress-to-string conversion rules for the current field;
                if the outcome of the rulebook is the terminate conversion outcome:[failure]
                    remove focus from the current field;
                    follow the window-drawing rules for the assigned window of the current field;
                    now field-input mode is false;
                    break;
                if the outcome of the rulebook is the restart conversion outcome:[failure]
                    follow the window-drawing rules for the assigned window of the current field;
                    now field-input mode is false;
                    now field input interrupted is true;
                    break;
                follow the window-drawing rules for the assigned window of the current field;
        end the handling field input activity;
        if field input interrupted is true:
            JUMP TO FieldInput.[If we have clicked on a field rather than typing a keystroke, jump back to the beginning and restart the process with the new field.]

    To set jump point FieldInput:
        (- .FieldInput; -)
        
    To jump to FieldInput:
        (- jump FieldInput; -)