# To subscribers of the xforms list from "T.C. Zhao" <tc_zhao@yahoo.com> :
Thanks for attaching the test program. It'll be looked at
soon.
--- rob.carpenter@lmco.com wrote:
> # 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,
> c);fflush(stdout);
> if (isxdigit(c))
> return((FL_INPUTVALIDATOR)FL_VALID);
> else
> return((FL_INPUTVALIDATOR)(FL_INVALID|FL_RINGBELL));
> }
>
> /**** 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)
> {
> fl_finish();
> exit(0);
> }
>
> 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_object_return(fd_input->norminput,FL_RETURN_ALWAYS);
> fl_set_input_maxchars(fd_input->norminput, 8);
> fl_set_input_filter(fd_input->norminput,
> (FL_INPUTVALIDATOR)hex_filter);
>
> /* show the first form */
>
>
fl_show_form(fd_input->input,FL_PLACE_CENTERFREE,FL_FULLBORDER,"input");
>
> 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 =
> fl_add_input(FL_NORMAL_INPUT,40,40,340,30,"NormalInput");
> fl_set_object_lalign(obj,FL_ALIGN_TOP_LEFT);
> fl_set_object_callback(obj,input_cb,0);
> obj = fl_add_button(FL_NORMAL_BUTTON,330,400,70,30,"Done");
> fl_set_object_callback(obj,done_cb,0);
> fl_end_form();
>
> fl_adjust_form_size(fdui->input);
> fdui->input->fdui = fdui;
>
> return fdui;
> }
> /*---------------------------------------*/
>
>
>
> _________________________________________________
> To unsubscribe, send the message "unsubscribe" to
> xforms-request@bob.usuhs.mil or see
> http://bob.usuhs.mil/mailserv/xforms.html
> XForms Home Page: http://world.std.com/~xforms
> List Archive: http://bob.usuhs.mil/mailserv/list-archives/
>
__________________________________________________
Do You Yahoo!?
Yahoo! Photos -- now, 100 FREE prints!
http://photos.yahoo.com
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://world.std.com/~xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/
This archive was generated by hypermail 2b29 : Thu Jun 08 2000 - 10:56:21 EDT