XForms: input fields

From: rob.carpenter@lmco.com
Date: Wed Jun 07 2000 - 16:18:25 EDT

  • Next message: Eduardo Lluna: "XForms: Chinese fonts"

    # To subscribers of the xforms list from rob.carpenter@lmco.com :

    The following program is a modified version of one
    of the example programs. It creates a form with
    one input field with a filter, and maximum characters
    set to 8.

    I've noticed that if the field has the maximum characters (8)
    entered, and if part of that field is selected, the next
    keystroke causes an incorrect replacement of the selected
    region. In fact, it requires two keystrokes to change
    the field. It works fine if the field has less than
    the maximum characters.

    Also, why is the filter called twice for each keystroke.

    Am I doing something incorrectly?

    Machine: DEC Personal Workstation 433au
    OS: DEC Unix 4.0d
    Xforms: V0.89

    #include "forms.h"
    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>

    /** Callbacks, globals and object handlers **/
    extern void input_cb(FL_OBJECT *, long);
    extern void done_cb(FL_OBJECT *, long);

    FL_INPUTVALIDATOR hex_filter(FL_OBJECT *ob, const char *old, const char
    *cur, int c)
        printf("old (%s) new (%s) (%c) (%x)\n", old, cur, c,
        if (isxdigit(c))

    /**** Forms and Objects ****/
    typedef struct {
            FL_FORM *input;
            void *vdata;
            char *cdata;
            long ldata;
            FL_OBJECT *norminput;
    } FD_input;

    extern FD_input * create_form_input(void);

    /* callbacks for form input */
    void done_cb(FL_OBJECT *ob, long data)

    void input_cb(FL_OBJECT *ob, long data)
        printf("get_input (%s)\n", fl_get_input(ob));

    int main(int argc, char *argv[])
        FD_input *fd_input;

        fl_initialize(&argc, argv, 0, 0, 0);
        fd_input = create_form_input();

        /* fill-in form initialization code */
        fl_set_input_maxchars(fd_input->norminput, 8);
        fl_set_input_filter(fd_input->norminput, (FL_INPUTVALIDATOR)hex_filter);

        /* show the first form */

        while (fl_do_forms()) ;
        return 0;

    /* Form definition file generated with fdesign. */

    FD_input *create_form_input(void)
      FL_OBJECT *obj;
      FD_input *fdui = (FD_input *) fl_calloc(1, sizeof(*fdui));

      fdui->input = fl_bgn_form(FL_NO_BOX, 440, 440);
      obj = fl_add_box(FL_UP_BOX,0,0,440,440,"");
      fdui->norminput = obj =
      obj = fl_add_button(FL_NORMAL_BUTTON,330,400,70,30,"Done");

      fdui->input->fdui = fdui;

      return fdui;

    To unsubscribe, send the message "unsubscribe" to
    xforms-request@bob.usuhs.mil or see
    XForms Home Page: http://world.std.com/~xforms
    List Archive: http://bob.usuhs.mil/mailserv/list-archives/

    This archive was generated by hypermail 2b29 : Wed Jun 07 2000 - 16:27:11 EDT